Skip to content

Commit 274782f

Browse files
Merge branch 'master' into gherkin_expanded_option_improved
2 parents d2ae789 + 5678a5c commit 274782f

File tree

11 files changed

+140
-68
lines changed

11 files changed

+140
-68
lines changed

.travis.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,39 @@
11
sudo: false
22
language: python
3-
python: "3.4"
4-
env:
5-
matrix:
6-
- TESTENV=linters
7-
- TESTENV=py27
8-
# - TESTENV=py27-xdist
9-
- TESTENV=py27-pytest-latest
10-
- TESTENV=py34
11-
- TESTENV=coveralls
3+
python: "2.7"
4+
5+
matrix:
6+
include:
7+
- env: TOXENV=py27-pytestlatest-linters
8+
- env: TOXENV=py27-pytest29
9+
- env: TOXENV=py27-pytest30
10+
- env: TOXENV=py27-pytest31
11+
- env: TOXENV=py27-pytest32
12+
- env: TOXENV=py27-pytest33
13+
- env: TOXENV=py27-pytest34
14+
- env: TOXENV=py27-pytest35
15+
- env: TOXENV=py27-pytest36
16+
- env: TOXENV=py27-pytest37
17+
- env: TOXENV=py27-pytest38
18+
- env: TOXENV=py27-pytest39
19+
- env: TOXENV=py27-pytestlatest
20+
- env: TOXENV=py27-pytestlatest-xdist
21+
- env: TOXENV=py34-pytestlatest
22+
python: "3.4"
23+
- env: TOXENV=py35-pytestlatest
24+
python: "3.5"
25+
- env: TOXENV=py36-pytestlatest
26+
python: "3.6"
27+
- env: TOXENV=py37-pytestlatest
28+
python: "3.7"
29+
# Currently, python 3.7 is a little bit tricky to install:
30+
# https://github.com/travis-ci/travis-ci/issues/9069#issuecomment-425720905
31+
sudo: required
32+
dist: xenial
33+
- env: TOXENV=py27-pytestlatest-coveralls
1234
install:
1335
- pip install tox
14-
script: tox -e $TESTENV --recreate
36+
script: tox --recreate
1537
branches:
1638
except:
1739
- /^\d/

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
3.0.1
5+
------
6+
7+
- Minimal supported version of `pytest` is now 2.9.0 as lower versions do not support `bool` type ini options (sliwinski-milosz) #260
8+
49
3.0.0
510
------
611

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ If you used ``pytestbdd_feature_base_dir`` fixture to override the path discover
12281228
12291229
For more details, check the `Feature file paths`_ section.
12301230

1231-
If you used ``pytestbdd_strict_gherkin`` fixture to relax the parser, you can instead specify ``strict_gherking=False`` in the declaration of your scenarios, or change it globally in the pytest configuration file:
1231+
If you used ``pytestbdd_strict_gherkin`` fixture to relax the parser, you can instead specify ``strict_gherkin=False`` in the declaration of your scenarios, or change it globally in the pytest configuration file:
12321232

12331233
.. code-block:: ini
12341234

pytest_bdd/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
from pytest_bdd.steps import given, when, then
44
from pytest_bdd.scenario import scenario, scenarios
55

6-
__version__ = '3.0.0'
6+
__version__ = '3.0.1'
77

88
__all__ = [given.__name__, when.__name__, then.__name__, scenario.__name__, scenarios.__name__]

pytest_bdd/reporting.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import time
88

99
from .feature import force_unicode
10+
from .utils import get_parametrize_markers_args
1011

1112

1213
class StepReport(object):
@@ -73,11 +74,11 @@ def __init__(self, scenario, node):
7374
self.scenario = scenario
7475
self.step_reports = []
7576
self.param_index = None
76-
parametrize = node.keywords._markers.get('parametrize')
77-
if parametrize and scenario.examples:
78-
param_names = parametrize.args[0] if isinstance(parametrize.args[0], (tuple, list)) else [
79-
parametrize.args[0]]
80-
param_values = parametrize.args[1]
77+
parametrize_args = get_parametrize_markers_args(node)
78+
if parametrize_args and scenario.examples:
79+
param_names = parametrize_args[0] if isinstance(parametrize_args[0], (tuple, list)) else [
80+
parametrize_args[0]]
81+
param_values = parametrize_args[1]
8182
node_param_values = [node.funcargs[param_name] for param_name in param_names]
8283
if node_param_values in param_values:
8384
self.param_index = param_values.index(node_param_values)

pytest_bdd/utils.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,29 @@ def get_request_fixture_names(request):
8484
Compatibility with pytest 3.0.
8585
"""
8686
return request._pyfuncitem._fixtureinfo.names_closure
87+
88+
89+
def get_parametrize_markers_args(node):
90+
"""In pytest 3.6 new API to access markers has been introduced and it deprecated
91+
MarkInfo objects.
92+
93+
This function uses that API if it is available otherwise it uses MarkInfo objects.
94+
"""
95+
mark_name = 'parametrize'
96+
try:
97+
return get_markers_args_using_iter_markers(node, mark_name)
98+
except AttributeError:
99+
return get_markers_args_using_get_marker(node, mark_name)
100+
101+
102+
def get_markers_args_using_iter_markers(node, mark_name):
103+
"""Recommended on pytest>=3.6"""
104+
args = []
105+
for mark in node.iter_markers(mark_name):
106+
args += mark.args
107+
return tuple(args)
108+
109+
110+
def get_markers_args_using_get_marker(node, mark_name):
111+
"""Deprecated on pytest>=3.6"""
112+
return getattr(node.get_marker(mark_name), 'args', ())

requirements-testing.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ mock
22
pytest-pep8
33
coverage<4.0a1
44
pytest-cache
5-
pytest-xdist

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def run_tests(self):
7676
"parse",
7777
"parse_type",
7878
"py",
79-
"pytest>=2.8.1",
79+
"pytest>=2.9.0",
8080
"six>=1.9.0",
8181
],
8282
# the following makes a plugin available to py.test

tests/feature/test_outline.py

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66

77
from pytest_bdd import given, when, then, scenario
88
from pytest_bdd import exceptions
9+
from pytest_bdd.utils import get_parametrize_markers_args
910

1011

1112
@scenario(
1213
'outline.feature',
1314
'Outlined given, when, thens',
1415
example_converters=dict(start=int, eat=float, left=str)
1516
)
16-
def test_outlined():
17-
assert test_outlined.parametrize.args == (
17+
def test_outlined(request):
18+
assert get_parametrize_markers_args(request.node) == (
1819
[u'start', u'eat', u'left'], [[12, 5.0, '7'], [5, 4.0, '1']])
1920

2021

@@ -133,35 +134,12 @@ def test_outlined_with_other_fixtures(other_fixture):
133134
'Outlined with vertical example table',
134135
example_converters=dict(start=int, eat=float, left=str)
135136
)
136-
def test_vertical_example():
137+
def test_vertical_example(request):
137138
"""Test outlined scenario with vertical examples table."""
138-
assert test_vertical_example.parametrize.args == (
139+
assert get_parametrize_markers_args(request.node) == (
139140
[u'start', u'eat', u'left'], [[12, 5.0, '7'], [2, 1.0, '1']])
140141

141142

142-
def test_empty_example_values():
143-
"""Test outlined scenario with empty example values."""
144-
@scenario(
145-
'outline.feature',
146-
'Outlined with empty example values',
147-
)
148-
def test_scenario():
149-
pass
150-
151-
assert test_scenario.parametrize.args == (
152-
[u'start', u'eat', u'left'], [['#', '', '']])
153-
154-
@scenario(
155-
'outline.feature',
156-
'Outlined with empty example values vertical',
157-
)
158-
def test_scenario():
159-
pass
160-
161-
assert test_scenario.parametrize.args == (
162-
[u'start', u'eat', u'left'], [['#', '', '']])
163-
164-
165143
@given('there are <start> <fruits>')
166144
def start_fruits(start, fruits):
167145
assert isinstance(start, int)
@@ -187,8 +165,8 @@ def should_have_left_fruits(start_fruits, start, eat, left, fruits):
187165
'Outlined given, when, thens',
188166
example_converters=dict(start=int, eat=float, left=str)
189167
)
190-
def test_outlined_feature():
191-
assert test_outlined_feature.parametrize.args == (
168+
def test_outlined_feature(request):
169+
assert get_parametrize_markers_args(request.node) == (
192170
['start', 'eat', 'left'],
193171
[[12, 5.0, '7'], [5, 4.0, '1']],
194172
['fruits'],
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""Scenario Outline with empty example values tests."""
2+
from pytest_bdd import given, scenario, then, when
3+
from pytest_bdd.utils import get_parametrize_markers_args
4+
5+
6+
@given('there are <start> cucumbers')
7+
def start_cucumbers(start):
8+
pass
9+
10+
11+
@when('I eat <eat> cucumbers')
12+
def eat_cucumbers(eat):
13+
pass
14+
15+
16+
@then('I should have <left> cucumbers')
17+
def should_have_left_cucumbers(left):
18+
pass
19+
20+
21+
@scenario(
22+
'outline.feature',
23+
'Outlined with empty example values',
24+
)
25+
def test_scenario_with_empty_example_values(request):
26+
assert get_parametrize_markers_args(request.node) == (
27+
[u'start', u'eat', u'left'], [['#', '', '']])
28+
29+
30+
@scenario(
31+
'outline.feature',
32+
'Outlined with empty example values vertical',
33+
)
34+
def test_scenario_with_empty_example_values_vertical(request):
35+
assert get_parametrize_markers_args(request.node) == (
36+
[u'start', u'eat', u'left'], [['#', '', '']])

0 commit comments

Comments
 (0)