def test_scenario_not_found(request): """Test the situation when scenario is not found.""" with pytest.raises(exceptions.ScenarioNotFound) as exc_info: scenario( 'not_found.feature', 'NOT FOUND' ) assert six.text_type(exc_info.value).startswith( 'Scenario "NOT FOUND" in feature "[Empty]" in {feature_path}' .format(feature_path=request.fspath.join('..', 'not_found.feature')))
def test_verbose_output(): """Test verbose output of failed feature scenario.""" with pytest.raises(exceptions.FeatureError) as excinfo: scenario('when_after_then.feature', 'When after then') msg, line_number, line, file = excinfo.value.args assert line_number == 5 assert line == 'When I do it again' assert file == os.path.join(os.path.dirname(__file__), 'when_after_then.feature') assert line in str(excinfo.value)
def test_scenario_not_decorator(request): """Test scenario function is used not as decorator.""" func = scenario( 'comments.feature', 'Strings that are not comments') with pytest.raises(exceptions.ScenarioIsDecoratorOnly): func(request)
def test_feature_path(request, scenario_name): """Test feature base dir.""" with pytest.raises(IOError) as exc: scenario('tests.feature', scenario_name) assert os.path.join('/does/not/exist/', 'tests.feature') in str(exc.value)