Merge pull request #70 from bubenkoff/better-scenario-not-found

Better reporting of a not found scenario
This commit is contained in:
Oleg Pidsadnyi 2014-09-19 21:04:10 +02:00
commit c21dda176c
3 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,12 @@
Changelog Changelog
========= =========
Unreleased
----------
- Better reporting of a not found scenario (bubenkoff)
2.4.0 2.4.0
----- -----

View File

@ -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

View File

@ -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):