BDD for pytest
Project description
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.
Example
publish_article.feature:
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
test_publish_article.py:
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(article.id)))
@when('I press the publish button')
def publish_article(browser):
browser.find_by_css('button[name=publish]').first.click()
@then('I should not see the error message')
def no_error_message(browser):
with pytest.raises(ElementDoesNotExist):
browser.find_by_css('.message.error').first
@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
Installation
$ pip install pytest-bdd
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytest-bdd-0.4.6.tar.gz
(7.3 kB
view details)
File details
Details for the file pytest-bdd-0.4.6.tar.gz
.
File metadata
- Download URL: pytest-bdd-0.4.6.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e8a306eac5c56861dcb9aa7cbfcbcedf1dbc242f077f60402717b2148366c9c |
|
MD5 | 9f7e7cf73bccf3cf57b00fdb0a2450a3 |
|
BLAKE2b-256 | 99d10fbb7bef36f71c3b2714e9314623cf36cf970a498f7f39b6c097eb48e208 |