Merge pull request #70 from bubenkoff/better-scenario-not-found
Better reporting of a not found scenario
This commit is contained in:
commit
c21dda176c
|
@ -1,6 +1,12 @@
|
||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
Unreleased
|
||||||
|
----------
|
||||||
|
|
||||||
|
- Better reporting of a not found scenario (bubenkoff)
|
||||||
|
|
||||||
|
|
||||||
2.4.0
|
2.4.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,10 @@ def scenario(
|
||||||
scenario = feature.scenarios[scenario_name]
|
scenario = feature.scenarios[scenario_name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise exceptions.ScenarioNotFound(
|
raise exceptions.ScenarioNotFound(
|
||||||
'Scenario "{0}" in feature "{1}" is not found.'.format(scenario_name, feature_name)
|
'Scenario "{scenario_name}" in feature "{feature_name}" in {feature_filename} is not found.'.format(
|
||||||
|
scenario_name=scenario_name,
|
||||||
|
feature_name=feature.name or '[Empty]',
|
||||||
|
feature_filename=feature.filename)
|
||||||
)
|
)
|
||||||
|
|
||||||
scenario.example_converters = example_converters
|
scenario.example_converters = example_converters
|
||||||
|
|
|
@ -8,11 +8,13 @@ from pytest_bdd import exceptions
|
||||||
def test_scenario_not_found(request):
|
def test_scenario_not_found(request):
|
||||||
"""Test the situation when scenario is not found."""
|
"""Test the situation when scenario is not found."""
|
||||||
|
|
||||||
with pytest.raises(exceptions.ScenarioNotFound):
|
with pytest.raises(exceptions.ScenarioNotFound) as exc_info:
|
||||||
scenario(
|
scenario(
|
||||||
'not_found.feature',
|
'not_found.feature',
|
||||||
'NOT FOUND'
|
'NOT FOUND'
|
||||||
)
|
)
|
||||||
|
assert exc_info.value.args[0].startswith('Scenario "NOT FOUND" in feature "[Empty]" in {feature_path}'.format(
|
||||||
|
feature_path=request.fspath.join('..', 'not_found.feature')))
|
||||||
|
|
||||||
|
|
||||||
def test_scenario_comments(request):
|
def test_scenario_comments(request):
|
||||||
|
|
Loading…
Reference in New Issue