fix regex step deprecation

This commit is contained in:
Anatoly Bubenkov 2015-01-13 15:33:54 +01:00
parent 53f074d70c
commit a97cefd26c
3 changed files with 9 additions and 4 deletions

View File

@ -1,7 +1,7 @@
Changelog
=========
2.6.0
2.6.1
-----
- Correctly handle `pytest-bdd` command called without the subcommand under python3 (bubenkoff, spinus)

View File

@ -1,6 +1,6 @@
"""pytest-bdd public API."""
__version__ = '2.6.0'
__version__ = '2.6.1'
try:
from pytest_bdd.steps import given, when, then

View File

@ -2,11 +2,11 @@
from __future__ import absolute_import
import re as base_re
import warnings
import parse as base_parse
from parse_type import cfparse as base_cfparse
import pytest
import six
from .exceptions import InvalidStepParserError
@ -115,7 +115,12 @@ def get_parser(step_name):
"""
if isinstance(step_name, RE_TYPE):
# backwards compartibility
pytest.config.warn('bdd', "Direct usage of regex is deprecated. Please use pytest_bdd.parsers.re instead.")
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):
return string(step_name)