16
16
import re
17
17
18
18
import pytest
19
- from _pytest import python
19
+ try :
20
+ from _pytest import fixtures as pytest_fixtures
21
+ except ImportError :
22
+ from _pytest import python as pytest_fixtures
20
23
import six
21
24
22
25
from . import exceptions
@@ -69,7 +72,7 @@ def find_argumented_step_fixture_name(name, type_, fixturemanager, request=None)
69
72
if request :
70
73
try :
71
74
request .getfuncargvalue (parser_name )
72
- except python .FixtureLookupError :
75
+ except pytest_fixtures .FixtureLookupError :
73
76
continue
74
77
return parser_name
75
78
@@ -87,13 +90,13 @@ def _find_step_function(request, step, scenario, encoding):
87
90
name = step .name
88
91
try :
89
92
return request .getfuncargvalue (get_step_fixture_name (name , step .type , encoding ))
90
- except python .FixtureLookupError :
93
+ except pytest_fixtures .FixtureLookupError :
91
94
try :
92
95
name = find_argumented_step_fixture_name (name , step .type , request ._fixturemanager , request )
93
96
if name :
94
97
return request .getfuncargvalue (name )
95
98
raise
96
- except python .FixtureLookupError :
99
+ except pytest_fixtures .FixtureLookupError :
97
100
raise exceptions .StepDefinitionNotFoundError (
98
101
u"""Step definition is not found: {step}."""
99
102
""" Line {step.line_number} in scenario "{scenario.name}" in the feature "{feature.filename}""" .format (
@@ -234,7 +237,7 @@ def _get_scenario_decorator(feature, feature_name, scenario, scenario_name, call
234
237
scenario_name = force_encode (scenario_name , encoding )
235
238
236
239
def decorator (_pytestbdd_function ):
237
- if isinstance (_pytestbdd_function , python .FixtureRequest ):
240
+ if isinstance (_pytestbdd_function , pytest_fixtures .FixtureRequest ):
238
241
raise exceptions .ScenarioIsDecoratorOnly (
239
242
"scenario function can only be used as a decorator. Refer to the documentation." ,
240
243
)
0 commit comments