Skip to content

Commit 635dd3f

Browse files
committed
Remove compatibility code for ancient versions of pytest
1 parent c197799 commit 635dd3f

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

pytest_bdd/scenario.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
import re
1616

1717
import pytest
18-
19-
try:
20-
from _pytest import fixtures as pytest_fixtures
21-
except ImportError:
22-
from _pytest import python as pytest_fixtures
18+
from _pytest.fixtures import FixtureLookupError
2319

2420
from . import exceptions
2521
from .feature import get_feature, get_features
@@ -52,7 +48,7 @@ def find_argumented_step_fixture_name(name, type_, fixturemanager, request=None)
5248
if request:
5349
try:
5450
request.getfixturevalue(parser_name)
55-
except pytest_fixtures.FixtureLookupError:
51+
except FixtureLookupError:
5652
continue
5753
return parser_name
5854

@@ -71,14 +67,14 @@ def _find_step_function(request, step, scenario):
7167
try:
7268
# Simple case where no parser is used for the step
7369
return request.getfixturevalue(get_step_fixture_name(name, step.type))
74-
except pytest_fixtures.FixtureLookupError:
70+
except FixtureLookupError:
7571
try:
7672
# Could not find a fixture with the same name, let's see if there is a parser involved
7773
name = find_argumented_step_fixture_name(name, step.type, request._fixturemanager, request)
7874
if name:
7975
return request.getfixturevalue(name)
8076
raise
81-
except pytest_fixtures.FixtureLookupError:
77+
except FixtureLookupError:
8278
raise exceptions.StepDefinitionNotFoundError(
8379
f"Step definition is not found: {step}. "
8480
f'Line {step.line_number} in scenario "{scenario.name}" in the feature "{scenario.feature.filename}"'

pytest_bdd/steps.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ def given_beautiful_article(article):
3737

3838
import pytest
3939

40-
try:
41-
from _pytest import fixtures as pytest_fixtures
42-
except ImportError:
43-
from _pytest import python as pytest_fixtures
40+
from _pytest.fixtures import FixtureDef
4441

4542
from .types import GIVEN, WHEN, THEN
4643
from .parsers import get_parser
@@ -154,10 +151,10 @@ def inject_fixture(request, arg, value):
154151
"params": None,
155152
}
156153

157-
if "yieldctx" in get_args(pytest_fixtures.FixtureDef.__init__):
154+
if "yieldctx" in get_args(FixtureDef.__init__):
158155
fd_kwargs["yieldctx"] = False
159156

160-
fd = pytest_fixtures.FixtureDef(**fd_kwargs)
157+
fd = FixtureDef(**fd_kwargs)
161158
fd.cached_result = (value, 0, None)
162159

163160
old_fd = request._fixture_defs.get(arg)

0 commit comments

Comments
 (0)