Skip to content

Commit c298a3e

Browse files
youtuxolegpidsadnyi
authored andcommitted
Do not accept regex as step definitions
1 parent 744e855 commit c298a3e

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

pytest_bdd/parsers.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,8 @@ def get_parser(step_name):
113113
:return: step parser object
114114
:rtype: StepArgumentParser
115115
"""
116-
if isinstance(step_name, RE_TYPE):
117-
# backwards compartibility
118-
warn = (
119-
'pytest-bdd [{0}]: Direct usage of regex is deprecated. Please use pytest_bdd.parsers.re instead.'.format(
120-
step_name.pattern)
121-
)
122-
warnings.warn(warn)
123-
print(warn)
124-
return re(step_name.pattern, flags=step_name.flags)
125-
elif isinstance(step_name, six.string_types):
126-
if isinstance(step_name, six.binary_type):
116+
if isinstance(step_name, six.string_types):
117+
if isinstance(step_name, six.binary_type): # Python 2 compatibility
127118
step_name = step_name.decode('utf-8')
128119
return string(step_name)
129120
elif not hasattr(step_name, 'is_matching') or not hasattr(step_name, 'parse_arguments'):

tests/args/regex/test_args.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ def i_should_have(euro, values):
5858
assert euro == values.pop(0)
5959

6060

61-
# test backwards compartibility
62-
@given(re.compile(r'I have an argument (?P<arg>\d+)'))
61+
@given(parsers.re(r'I have an argument (?P<arg>\d+)'))
6362
def argument(arg):
6463
"""I have an argument."""
6564
return dict(arg=arg)

0 commit comments

Comments
 (0)