forked from test_framework/pytest-bdd
bdd_feature_base_dir renamed into bdd_features_base_dir
This commit is contained in:
parent
ed45c5e9fc
commit
7671290ad0
|
@ -37,8 +37,8 @@ def pytest_addoption(parser):
|
||||||
|
|
||||||
|
|
||||||
def add_bdd_ini(parser):
|
def add_bdd_ini(parser):
|
||||||
parser.addini('bdd_feature_base_dir',
|
parser.addini('bdd_features_base_dir',
|
||||||
'Base feature directory.')
|
'Base features directory.')
|
||||||
parser.addini('bdd_strict_gherkin',
|
parser.addini('bdd_strict_gherkin',
|
||||||
'Parse features to be strict gherkin.',
|
'Parse features to be strict gherkin.',
|
||||||
type='bool', default=True)
|
type='bool', default=True)
|
||||||
|
|
|
@ -258,7 +258,7 @@ def _get_scenario_decorator(feature, feature_name, scenario, scenario_name, call
|
||||||
|
|
||||||
|
|
||||||
def scenario(feature_name, scenario_name, encoding="utf-8", example_converters=None,
|
def scenario(feature_name, scenario_name, encoding="utf-8", example_converters=None,
|
||||||
caller_module=None, caller_function=None, feature_base_dir=None, strict_gherkin=None):
|
caller_module=None, caller_function=None, features_base_dir=None, strict_gherkin=None):
|
||||||
"""Scenario decorator.
|
"""Scenario decorator.
|
||||||
|
|
||||||
:param str feature_name: Feature file name. Absolute or relative to the configured feature base path.
|
:param str feature_name: Feature file name. Absolute or relative to the configured feature base path.
|
||||||
|
@ -272,11 +272,11 @@ def scenario(feature_name, scenario_name, encoding="utf-8", example_converters=N
|
||||||
caller_function = caller_function or get_caller_function()
|
caller_function = caller_function or get_caller_function()
|
||||||
|
|
||||||
# Get the feature
|
# Get the feature
|
||||||
if feature_base_dir is None:
|
if features_base_dir is None:
|
||||||
feature_base_dir = get_feature_base_dir(caller_module)
|
features_base_dir = get_features_base_dir(caller_module)
|
||||||
if strict_gherkin is None:
|
if strict_gherkin is None:
|
||||||
strict_gherkin = get_strict_gherkin()
|
strict_gherkin = get_strict_gherkin()
|
||||||
feature = Feature.get_feature(feature_base_dir, feature_name, encoding=encoding, strict_gherkin=strict_gherkin)
|
feature = Feature.get_feature(features_base_dir, feature_name, encoding=encoding, strict_gherkin=strict_gherkin)
|
||||||
|
|
||||||
# Get the sc_enario
|
# Get the sc_enario
|
||||||
try:
|
try:
|
||||||
|
@ -306,9 +306,9 @@ def scenario(feature_name, scenario_name, encoding="utf-8", example_converters=N
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_feature_base_dir(caller_module):
|
def get_features_base_dir(caller_module):
|
||||||
default_base_dir = os.path.dirname(caller_module.__file__)
|
default_base_dir = os.path.dirname(caller_module.__file__)
|
||||||
return get_from_ini('bdd_feature_base_dir', default_base_dir)
|
return get_from_ini('bdd_features_base_dir', default_base_dir)
|
||||||
|
|
||||||
|
|
||||||
def get_from_ini(key, default):
|
def get_from_ini(key, default):
|
||||||
|
@ -352,9 +352,9 @@ def scenarios(*feature_paths, **kwargs):
|
||||||
frame = inspect.stack()[1]
|
frame = inspect.stack()[1]
|
||||||
module = inspect.getmodule(frame[0])
|
module = inspect.getmodule(frame[0])
|
||||||
|
|
||||||
feature_base_dir = kwargs.get('feature_base_dir')
|
features_base_dir = kwargs.get('features_base_dir')
|
||||||
if feature_base_dir is None:
|
if features_base_dir is None:
|
||||||
feature_base_dir = get_feature_base_dir(module)
|
features_base_dir = get_features_base_dir(module)
|
||||||
|
|
||||||
strict_gherkin = kwargs.get('strict_gherkin')
|
strict_gherkin = kwargs.get('strict_gherkin')
|
||||||
if strict_gherkin is None:
|
if strict_gherkin is None:
|
||||||
|
@ -363,7 +363,7 @@ def scenarios(*feature_paths, **kwargs):
|
||||||
abs_feature_paths = []
|
abs_feature_paths = []
|
||||||
for path in feature_paths:
|
for path in feature_paths:
|
||||||
if not os.path.isabs(path):
|
if not os.path.isabs(path):
|
||||||
path = os.path.abspath(os.path.join(feature_base_dir, path))
|
path = os.path.abspath(os.path.join(features_base_dir, path))
|
||||||
abs_feature_paths.append(path)
|
abs_feature_paths.append(path)
|
||||||
found = False
|
found = False
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ def test_feature_path_by_param_ok(testdir, base_dir):
|
||||||
def prepare_testdir(testdir, ini_base_dir):
|
def prepare_testdir(testdir, ini_base_dir):
|
||||||
testdir.makeini("""
|
testdir.makeini("""
|
||||||
[pytest]
|
[pytest]
|
||||||
bdd_feature_base_dir={}
|
bdd_features_base_dir={}
|
||||||
""".format(ini_base_dir))
|
""".format(ini_base_dir))
|
||||||
|
|
||||||
feature_file = testdir.mkdir('features').join('steps.feature')
|
feature_file = testdir.mkdir('features').join('steps.feature')
|
||||||
|
@ -112,9 +112,9 @@ def prepare_testdir(testdir, ini_base_dir):
|
||||||
def test_not_found_by_param(scenario_name, param_base_dir, multiple):
|
def test_not_found_by_param(scenario_name, param_base_dir, multiple):
|
||||||
with pytest.raises(IOError) as exc:
|
with pytest.raises(IOError) as exc:
|
||||||
if multiple:
|
if multiple:
|
||||||
scenarios(FEATURE, feature_base_dir=param_base_dir)
|
scenarios(FEATURE, features_base_dir=param_base_dir)
|
||||||
else:
|
else:
|
||||||
scenario(FEATURE, scenario_name, feature_base_dir=param_base_dir)
|
scenario(FEATURE, scenario_name, features_base_dir=param_base_dir)
|
||||||
assert os.path.abspath(os.path.join(param_base_dir, FEATURE)) in str(exc.value)
|
assert os.path.abspath(os.path.join(param_base_dir, FEATURE)) in str(exc.value)
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,10 +122,10 @@ def prepare_testdir(testdir, ini_base_dir):
|
||||||
'multiple', [True, False]
|
'multiple', [True, False]
|
||||||
)
|
)
|
||||||
def test_ok_by_param(scenario_name, multiple):
|
def test_ok_by_param(scenario_name, multiple):
|
||||||
# Shouldn't raise any exception no matter of bdd_feature_base_dir in ini
|
# Shouldn't raise any exception no matter of bdd_features_base_dir in ini
|
||||||
if multiple:
|
if multiple:
|
||||||
scenarios(FEATURE, feature_base_dir='features')
|
scenarios(FEATURE, features_base_dir='features')
|
||||||
else:
|
else:
|
||||||
scenario(FEATURE, scenario_name, feature_base_dir='features')
|
scenario(FEATURE, scenario_name, features_base_dir='features')
|
||||||
|
|
||||||
""".format(ini_base_dir))
|
""".format(ini_base_dir))
|
||||||
|
|
Loading…
Reference in New Issue