Skip to content

Commit ee05a10

Browse files
youtuxolegpidsadnyi
authored andcommitted
drop compatibility with pytest < 3.0.0
1 parent 873cd82 commit ee05a10

File tree

10 files changed

+21
-34
lines changed

10 files changed

+21
-34
lines changed

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+
Unreleased
5+
----------
6+
7+
- Drop support for pytest < 3.0
8+
49
3.0.2
510
------
611

pytest_bdd/scenario.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
recreate_function,
3939
)
4040
from .types import GIVEN
41-
from .utils import CONFIG_STACK, get_args, get_fixture_value
41+
from .utils import CONFIG_STACK, get_args
4242

4343
if six.PY3: # pragma: no cover
4444
import runpy
@@ -70,7 +70,7 @@ def find_argumented_step_fixture_name(name, type_, fixturemanager, request=None)
7070
parser_name = get_step_fixture_name(parser.name, type_)
7171
if request:
7272
try:
73-
get_fixture_value(request, parser_name)
73+
request.getfixturevalue(parser_name)
7474
except pytest_fixtures.FixtureLookupError:
7575
continue
7676
return parser_name
@@ -88,12 +88,12 @@ def _find_step_function(request, step, scenario, encoding):
8888
"""
8989
name = step.name
9090
try:
91-
return get_fixture_value(request, get_step_fixture_name(name, step.type, encoding))
91+
return request.getfixturevalue(get_step_fixture_name(name, step.type, encoding))
9292
except pytest_fixtures.FixtureLookupError:
9393
try:
9494
name = find_argumented_step_fixture_name(name, step.type, request._fixturemanager, request)
9595
if name:
96-
return get_fixture_value(request, name)
96+
return request.getfixturevalue(name)
9797
raise
9898
except pytest_fixtures.FixtureLookupError:
9999
raise exceptions.StepDefinitionNotFoundError(
@@ -128,7 +128,7 @@ def _execute_step_function(request, scenario, step, step_func):
128128
kw["step_func_args"] = {}
129129
try:
130130
# Get the step argument values.
131-
kwargs = dict((arg, get_fixture_value(request, arg)) for arg in get_args(step_func))
131+
kwargs = dict((arg, request.getfixturevalue(arg)) for arg in get_args(step_func))
132132
kw["step_func_args"] = kwargs
133133

134134
request.config.hook.pytest_bdd_before_step_call(**kw)

pytest_bdd/steps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def article(author):
4949
StepError,
5050
)
5151
from .parsers import get_parser
52-
from .utils import get_args, get_fixture_value, get_fixture_value_raw, set_fixture_value, get_request_fixture_defs, \
52+
from .utils import get_args, get_fixture_value_raw, set_fixture_value, get_request_fixture_defs, \
5353
get_request_fixture_names
5454

5555

@@ -82,7 +82,7 @@ def given(name, fixture=None, converters=None, scope='function', target_fixture=
8282
module = get_caller_module()
8383

8484
def step_func(request):
85-
return get_fixture_value(request, fixture)
85+
return request.getfixturevalue(fixture)
8686

8787
step_func.step_type = GIVEN
8888
step_func.converters = converters
@@ -162,7 +162,7 @@ def decorator(func):
162162
func = pytest.fixture(scope=scope)(func)
163163

164164
def step_func(request):
165-
result = get_fixture_value(request, func.__name__)
165+
result = request.getfixturevalue(func.__name__)
166166
if target_fixture:
167167
inject_fixture(request, target_fixture, result)
168168
return result

pytest_bdd/utils.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,6 @@ def get_args(func):
2525
return inspect.getargspec(func).args
2626

2727

28-
def get_fixture_value(request, name):
29-
"""Get the given fixture from the pytest request object.
30-
31-
getfuncargvalue() is deprecated in pytest 3.0, so we need to use
32-
getfixturevalue() there.
33-
"""
34-
try:
35-
getfixturevalue = request.getfixturevalue
36-
except AttributeError:
37-
getfixturevalue = request.getfuncargvalue
38-
return getfixturevalue(name)
39-
40-
4128
def get_fixture_value_raw(request, name):
4229
"""Set the given raw fixture value from the pytest request object.
4330

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.9.0",
79+
"pytest>=3.0.0",
8080
"six>=1.9.0",
8181
],
8282
# the following makes a plugin available to py.test

tests/feature/test_multiline.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
scenario,
1111
then,
1212
)
13-
from pytest_bdd.utils import get_fixture_value
1413

1514

1615
@pytest.mark.parametrize(["feature_text", "expected_text"], [
@@ -73,7 +72,7 @@ def test_multiline(request, tmpdir, feature_text, expected_text):
7372

7473
@scenario(file_name.strpath, 'Multiline step using sub indentation')
7574
def test_multiline(request):
76-
assert get_fixture_value(request, 'i_have_text') == expected_text
75+
assert request.getfixturevalue('i_have_text') == expected_text
7776
test_multiline(request)
7877

7978

tests/library/child/test_local_override.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from pytest_bdd import given
77
from pytest_bdd.steps import get_step_fixture_name, GIVEN
8-
from pytest_bdd.utils import get_fixture_value
98

109

1110
@given('I have locally overriden fixture')
@@ -22,11 +21,11 @@ def test_override(request, overridable):
2221
"""Test locally overriden fixture."""
2322

2423
# Test the fixture is also collected by the text name
25-
fixture = get_fixture_value(request, get_step_fixture_name('I have locally overriden fixture', GIVEN))
24+
fixture = request.getfixturevalue(get_step_fixture_name('I have locally overriden fixture', GIVEN))
2625
assert fixture(request) == 'local'
2726

2827
# 'I have the overriden fixture' stands for overridable and is overriden locally
29-
fixture = get_fixture_value(request, get_step_fixture_name('I have the overriden fixture', GIVEN))
28+
fixture = request.getfixturevalue(get_step_fixture_name('I have the overriden fixture', GIVEN))
3029
assert fixture(request) == 'local'
3130

3231
assert overridable == 'local'

tests/library/test_parent.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Check the parent givens are collected and overriden in the local conftest.
44
"""
55
from pytest_bdd.steps import get_step_fixture_name, WHEN
6-
from pytest_bdd.utils import get_fixture_value
76

87

98
def test_parent(parent, overridable):
@@ -17,4 +16,4 @@ def test_parent(parent, overridable):
1716

1817
def test_global_when_step(request):
1918
"""Test when step defined in the parent conftest."""
20-
get_fixture_value(request, get_step_fixture_name('I use a when step from the parent conftest', WHEN))
19+
request.getfixturevalue(get_step_fixture_name('I use a when step from the parent conftest', WHEN))

tests/steps/test_steps.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pytest
44
from pytest_bdd import given, when, then
55
from pytest_bdd.steps import get_step_fixture_name, WHEN, THEN
6-
from pytest_bdd.utils import get_fixture_value
76

87

98
@when('I do stuff')
@@ -22,10 +21,10 @@ def test_when_then(request):
2221
This test checks that when and then are not evaluated
2322
during fixture collection that might break the scenario.
2423
"""
25-
do_stuff_ = get_fixture_value(request, get_step_fixture_name('I do stuff', WHEN))
24+
do_stuff_ = request.getfixturevalue(get_step_fixture_name('I do stuff', WHEN))
2625
assert callable(do_stuff_)
2726

28-
check_stuff_ = get_fixture_value(request, get_step_fixture_name('I check stuff', THEN))
27+
check_stuff_ = request.getfixturevalue(get_step_fixture_name('I check stuff', THEN))
2928
assert callable(check_stuff_)
3029

3130

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
distshare={homedir}/.tox/distshare
3-
envlist=py27-pytestlatest-linters,py27-pytest{29,30,31,32,33,34,35,36,37,38,39,310,40,41,42,latest},py{34,35,36,37}-pytestlatest,py27-pytestlatest-xdist
3+
envlist=py27-pytestlatest-linters,py27-pytest{30,31,32,33,34,35,36,37,38,39,310,40,41,42,latest},py{34,35,36,37}-pytestlatest,py27-pytestlatest-xdist
44
skip_missing_interpreters = true
55

66
[testenv]
@@ -20,7 +20,6 @@ deps =
2020
pytest32: pytest~=3.2.0
2121
pytest31: pytest~=3.1.0
2222
pytest30: pytest~=3.0.0
23-
pytest29: pytest~=2.9.0
2423
pytest30,pytest29: pytest-warnings
2524
-r{toxinidir}/requirements-testing.txt
2625
commands = py.test tests --junitxml={envlogdir}/junit-{envname}.xml

0 commit comments

Comments
 (0)