Commit f0b13420 by Gabriel Falcao

fixing exclusionary tags behavior

parent dba55f98
...@@ -583,14 +583,19 @@ class Scenario(object): ...@@ -583,14 +583,19 @@ class Scenario(object):
if tags is None: if tags is None:
return True return True
if not self.tags: has_exclusionary_tags = any([t.startswith('-') for t in tags])
if not self.tags and not has_exclusionary_tags:
return False return False
matched = [] matched = []
for tag in self.tags: if isinstance(self.tags, list):
if tag in tags: for tag in self.tags:
return True if tag in tags:
return True
else:
self.tags = []
for tag in tags: for tag in tags:
exclude = tag.startswith('-') exclude = tag.startswith('-')
......
...@@ -497,6 +497,17 @@ def test_scenario_matches_tags_excluding(): ...@@ -497,6 +497,17 @@ def test_scenario_matches_tags_excluding():
assert scenario.matches_tags(['-foobar']) assert scenario.matches_tags(['-foobar'])
def test_scenario_matches_tags_excluding_when_scenario_has_no_tags():
("When Scenario#matches_tags is called for a scenario "
"that has no tags and the given match is a exclusionary tag")
scenario = Scenario.from_string(
SCENARIO1,
original_string=(SCENARIO1.strip()))
assert scenario.matches_tags(['-nope', '-neither'])
def test_scenario_matches_tags_excluding_fuzzywuzzy(): def test_scenario_matches_tags_excluding_fuzzywuzzy():
("When Scenario#matches_tags is called with a member starting with -~ " ("When Scenario#matches_tags is called with a member starting with -~ "
"it will exclude that tag from that fuzzywuzzy match") "it will exclude that tag from that fuzzywuzzy match")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment