Do not accept regex as step definitions

This commit is contained in:
Alessio Bogon 2019-02-19 13:11:00 +01:00 committed by Oleg Pidsadnyi
parent 744e855e01
commit c298a3edf5
2 changed files with 3 additions and 13 deletions

View File

@ -113,17 +113,8 @@ def get_parser(step_name):
:return: step parser object
:rtype: StepArgumentParser
"""
if isinstance(step_name, RE_TYPE):
# backwards compartibility
warn = (
'pytest-bdd [{0}]: Direct usage of regex is deprecated. Please use pytest_bdd.parsers.re instead.'.format(
step_name.pattern)
)
warnings.warn(warn)
print(warn)
return re(step_name.pattern, flags=step_name.flags)
elif isinstance(step_name, six.string_types):
if isinstance(step_name, six.binary_type):
if isinstance(step_name, six.string_types):
if isinstance(step_name, six.binary_type): # Python 2 compatibility
step_name = step_name.decode('utf-8')
return string(step_name)
elif not hasattr(step_name, 'is_matching') or not hasattr(step_name, 'parse_arguments'):

View File

@ -58,8 +58,7 @@ def i_should_have(euro, values):
assert euro == values.pop(0)
# test backwards compartibility
@given(re.compile(r'I have an argument (?P<arg>\d+)'))
@given(parsers.re(r'I have an argument (?P<arg>\d+)'))
def argument(arg):
"""I have an argument."""
return dict(arg=arg)