Fix example

This commit is contained in:
Alessio Bogon 2021-07-03 10:05:27 +02:00
parent 82c930f714
commit 2716593c47
1 changed files with 7 additions and 3 deletions

View File

@ -368,20 +368,24 @@ A common use case is when we have to assert the outcome of an HTTP request:
from pytest_bdd import scenarios, given, when, then
from my_app.models import Article
scenarios("blog.feature")
@given("there is an article", target_fixture="article")
def there_is_an_article():
return Article()
@when("I request the deletion of the article", target_fixture="request_result")
def there_should_be_a_new_article(article, http_client): # <-- Important bit here
def there_should_be_a_new_article(article, http_client):
return http_client.delete(f"/articles/{article.uid}")
@then("the request should be successful")
def article_is_published(request_result):
assert request_result.status_code = 200
assert request_result.status_code == 200
.. code-block:: gherkin