def test_getting_tags_from_model(): """ Test getting all Tags from a Model """ # given & when parent_model = Model(1, 'Model', 'I am a Model', 'foo.feature', 1, parent=None, tags=[Tag('some_tag')]) model = Model(1, 'Model', 'I am a Model', 'foo.feature', 1, parent=parent_model, tags=[Tag('foo'), Tag('bar')]) # when tags = model.all_tags # then assert len(tags) == 3 assert tags[0].name == 'some_tag' assert tags[1].name == 'foo' assert tags[2].name == 'bar'
def test_getting_tags_from_model(): """ Test getting all Tags from a Model """ # given & when parent_model = Model( 1, "Model", "I am a Model", "foo.feature", 1, parent=None, tags=[Tag("some_tag")], ) model = Model( 1, "Model", "I am a Model", "foo.feature", 1, parent=parent_model, tags=[Tag("foo"), Tag("bar")], ) # when tags = model.all_tags # then assert len(tags) == 3 assert tags[0].name == "some_tag" assert tags[1].name == "foo" assert tags[2].name == "bar"
def test_call_hooks_filtered_by_tags(hookregistry, mocker): """ Test calling filtered hooks by tags """ # given @after.all() def generic_cleanup(features, stub): stub() @after.all(on_tags="bad_case") def bad_case_cleanup(features, stub): stub() @after.all(on_tags="good_case") def good_case_cleanup(features, stub): stub() hook_call_stub = mocker.stub() model = mocker.MagicMock(all_tags=[]) models = [ mocker.MagicMock(all_tags=[Tag(name="good_case")]), mocker.MagicMock(all_tags=[Tag(name="bad_case")]), ] # when & then # all tags hookregistry.call("after", "all", True, model, hook_call_stub) assert hook_call_stub.call_count == 1 # only generic & good case model.all_tags = [Tag(name="good_case")] hookregistry.call("after", "all", True, model, hook_call_stub) assert hook_call_stub.call_count == 3 # only generic & bad case model.all_tags = [Tag(name="bad_case")] hookregistry.call("after", "all", True, model, hook_call_stub) assert hook_call_stub.call_count == 5 # good case & bad case because of model list hookregistry.call("after", "all", True, models, hook_call_stub) assert hook_call_stub.call_count == 8
def test_creating_a_tag(): """ Test creating a Tag """ # given & when tag = Tag('foo', arg='bar') # then assert tag.name == 'foo' assert tag.arg == 'bar'
def test_creating_a_tag(): """ Test creating a Tag """ # given & when tag = Tag("foo", arg="bar") # then assert tag.name == "foo" assert tag.arg == "bar"
@pytest.mark.parametrize('parser', [('step-text-data', )], indirect=['parser']) def test_parse_step_text_data(parser): """ Test parsing a Feature with a Scenario and Step with Text Data """ # when feature = parser.parse() # then assert len(feature.scenarios[0].steps) == 3 assert feature.scenarios[0].steps[0].text == 'To be or not to be' @pytest.mark.parametrize( 'parser, expected_feature_tags, expected_scenarios_tags', [(['tags-feature'], [Tag('foo'), Tag('bar')], [[]]), (['tags-scenario'], [], [[Tag('foo'), Tag('bar')]]), (['tags-everywhere'], [Tag('foo'), Tag('bar')], [[ Tag('regular_scenario') ], [Tag('scenario_outline')], [Tag('scenario_loop')]]), (['tags-arguments'], [Tag('foo', 'bar')], [[Tag('sometag', 'somevalue')]]) ], indirect=['parser']) def test_parse_tags(parser, expected_feature_tags, expected_scenarios_tags): """ Test parsing Feature and Scenario Tags """ # when feature = parser.parse() # then
def test_parse_step_text_data(parser): """ Test parsing a Feature with a Scenario and Step with Text Data """ # when feature = parser.parse() # then assert len(feature.scenarios[0].steps) == 3 assert feature.scenarios[0].steps[0].text == "To be or not to be" @pytest.mark.parametrize( "parser, expected_feature_tags, expected_scenarios_tags", [ (["tags-feature"], [Tag("foo"), Tag("bar")], [[]]), (["tags-scenario"], [], [[Tag("foo"), Tag("bar")]]), ( ["tags-everywhere"], [Tag("foo"), Tag("bar")], [ [Tag("regular_scenario")], [Tag("scenario_outline")], [Tag("scenario_loop")], ], ), (["tags-arguments"], [Tag("foo", "bar")], [[Tag("sometag", "somevalue")]]), ], indirect=["parser"], ) def test_parse_tags(parser, expected_feature_tags, expected_scenarios_tags):