@@ -44,10 +44,10 @@ Example
44
44
An example test for a blog hosting software could look like this.
45
45
Note that pytest-splinter _ is used to get the browser fixture.
46
46
47
- publish_article.feature:
48
-
49
47
.. code-block :: gherkin
50
48
49
+ # content of publish_article.feature
50
+
51
51
Feature: Blog
52
52
A site where you can publish your articles.
53
53
@@ -63,10 +63,10 @@ publish_article.feature:
63
63
64
64
Note that only one feature is allowed per feature file.
65
65
66
- test_publish_article.py:
67
-
68
66
.. code-block :: python
69
67
68
+ # content of test_publish_article.py
69
+
70
70
from pytest_bdd import scenario, given, when, then
71
71
72
72
@scenario (' publish_article.feature' , ' Publishing the article' )
@@ -349,7 +349,7 @@ A common use case is when we have to assert the outcome of an HTTP request:
349
349
350
350
.. code-block :: python
351
351
352
- # test_blog.py
352
+ # content of test_blog.py
353
353
354
354
from pytest_bdd import scenarios, given, when, then
355
355
@@ -375,7 +375,7 @@ A common use case is when we have to assert the outcome of an HTTP request:
375
375
376
376
.. code-block :: gherkin
377
377
378
- # blog.feature
378
+ # content of blog.feature
379
379
380
380
Feature: Blog
381
381
Scenario: Deleting the article
@@ -754,18 +754,18 @@ Reusing steps
754
754
It is possible to define some common steps in the parent conftest.py and
755
755
simply expect them in the child test file.
756
756
757
- common_steps.feature:
758
-
759
757
.. code-block :: gherkin
760
758
759
+ # content of common_steps.feature
760
+
761
761
Scenario: All steps are declared in the conftest
762
762
Given I have a bar
763
763
Then bar should have value "bar"
764
764
765
- conftest.py:
766
-
767
765
.. code-block :: python
768
766
767
+ # content of conftest.py
768
+
769
769
from pytest_bdd import given, then
770
770
771
771
@@ -778,10 +778,10 @@ conftest.py:
778
778
def bar_is_bar (bar ):
779
779
assert bar == " bar"
780
780
781
- test_common.py:
782
-
783
781
.. code-block :: python
784
782
783
+ # content of test_common.py
784
+
785
785
@scenario (" common_steps.feature" , " All steps are declared in the conftest" )
786
786
def test_conftest ():
787
787
pass
@@ -846,10 +846,10 @@ Avoid retyping the feature file name
846
846
If you want to avoid retyping the feature file name when defining your scenarios in a test file, use ``functools.partial ``.
847
847
This will make your life much easier when defining multiple scenarios in a test file. For example:
848
848
849
- test_publish_article.py:
850
-
851
849
.. code-block :: python
852
850
851
+ # content of test_publish_article.py
852
+
853
853
from functools import partial
854
854
855
855
import pytest_bdd
0 commit comments