forked from test_framework/pytest-bdd
Remove compatibility code for ancient versions of pytest
This commit is contained in:
parent
c197799e02
commit
635dd3f679
|
@ -15,11 +15,7 @@ import os
|
|||
import re
|
||||
|
||||
import pytest
|
||||
|
||||
try:
|
||||
from _pytest import fixtures as pytest_fixtures
|
||||
except ImportError:
|
||||
from _pytest import python as pytest_fixtures
|
||||
from _pytest.fixtures import FixtureLookupError
|
||||
|
||||
from . import exceptions
|
||||
from .feature import get_feature, get_features
|
||||
|
@ -52,7 +48,7 @@ def find_argumented_step_fixture_name(name, type_, fixturemanager, request=None)
|
|||
if request:
|
||||
try:
|
||||
request.getfixturevalue(parser_name)
|
||||
except pytest_fixtures.FixtureLookupError:
|
||||
except FixtureLookupError:
|
||||
continue
|
||||
return parser_name
|
||||
|
||||
|
@ -71,14 +67,14 @@ def _find_step_function(request, step, scenario):
|
|||
try:
|
||||
# Simple case where no parser is used for the step
|
||||
return request.getfixturevalue(get_step_fixture_name(name, step.type))
|
||||
except pytest_fixtures.FixtureLookupError:
|
||||
except FixtureLookupError:
|
||||
try:
|
||||
# Could not find a fixture with the same name, let's see if there is a parser involved
|
||||
name = find_argumented_step_fixture_name(name, step.type, request._fixturemanager, request)
|
||||
if name:
|
||||
return request.getfixturevalue(name)
|
||||
raise
|
||||
except pytest_fixtures.FixtureLookupError:
|
||||
except FixtureLookupError:
|
||||
raise exceptions.StepDefinitionNotFoundError(
|
||||
f"Step definition is not found: {step}. "
|
||||
f'Line {step.line_number} in scenario "{scenario.name}" in the feature "{scenario.feature.filename}"'
|
||||
|
|
|
@ -37,10 +37,7 @@ def given_beautiful_article(article):
|
|||
|
||||
import pytest
|
||||
|
||||
try:
|
||||
from _pytest import fixtures as pytest_fixtures
|
||||
except ImportError:
|
||||
from _pytest import python as pytest_fixtures
|
||||
from _pytest.fixtures import FixtureDef
|
||||
|
||||
from .types import GIVEN, WHEN, THEN
|
||||
from .parsers import get_parser
|
||||
|
@ -154,10 +151,10 @@ def inject_fixture(request, arg, value):
|
|||
"params": None,
|
||||
}
|
||||
|
||||
if "yieldctx" in get_args(pytest_fixtures.FixtureDef.__init__):
|
||||
if "yieldctx" in get_args(FixtureDef.__init__):
|
||||
fd_kwargs["yieldctx"] = False
|
||||
|
||||
fd = pytest_fixtures.FixtureDef(**fd_kwargs)
|
||||
fd = FixtureDef(**fd_kwargs)
|
||||
fd.cached_result = (value, 0, None)
|
||||
|
||||
old_fd = request._fixture_defs.get(arg)
|
||||
|
|
Loading…
Reference in New Issue