skip to navigation
skip to content

pytest-bdd 0.4.3

BDD for pytest

Latest Version: 2.20.0

Implements a subset of Gherkin language for the behavior-driven development and automated testing. Benefits from the pytest and its dependency injection pattern for the true just enough specifications and maximal reusability of the BDD definitions.



Scenario: Publishing the article
    Given I'm an author user
    And I have an article
    When I go to the article page
    And I press the publish button
    Then I should not see the error message
    And the article should be published  # Note: will query the database

from pytest_bdd import scenario, given, when, then

test_publish = scenario('publish_article.feature', 'Publishing the article')

@given('I have an article')
def article(author):
    return create_test_article(author=author)

@when('I go to the article page')
def go_to_article(article, browser):
    browser.visit(urljoin(browser.url, '/manage/articles/{0}/'.format(

@when('I press the publish button')
def publish_article(browser):

@then('I should not see the error message')
def no_error_message(browser):
    with pytest.raises(ElementDoesNotExist):

@then('And the article should be published')
def article_is_published(article):
    article.refresh()  # Refresh the object in the SQLAlchemy session
    assert article.is_published


$ pip install pytest-bdd
File Type Py Version Uploaded on Size
pytest-bdd-0.4.3.tar.gz (md5) Source 2013-06-16 6KB