Skip to content

Instantly share code, notes, and snippets.

@rwngwn
Last active October 26, 2015 11:51
Show Gist options
  • Save rwngwn/e3c2f08bd3402c78b7fd to your computer and use it in GitHub Desktop.
Save rwngwn/e3c2f08bd3402c78b7fd to your computer and use it in GitHub Desktop.

in behave you can specfy tags like:

--tags foo,bar --tags baz

I will call --tags foo,bar as a tag set what behave does is that it:

takes tag one by on in each set and if any of tag is in (is not for ~ negtion) tags for feature/scenatio its considers set to pass

if all set passes test is executed

code is:

    def check(self, tags):
        """
        Checks if this tag expression matches the tags of a model element.

        :param tags:  List of tags of a model element.
        :return: True, if tag expression matches. False, otherwise.
        """
        if not self.ands:
            return True

        element_tags = set(tags)

        def test_tag(xtag):
            if xtag.startswith('-'): # -- or xtag.startswith('~'):
                #print("debug")
                #print("%s --- %s" %(xtag[1:],element_tags))
                #print("result %s" %( xtag[1:] not in element_tags))
                return xtag[1:] not in element_tags
            return xtag in element_tags

        # -- EVALUATE: (or_expr1) and (or_expr2) and ...
        return all(any(test_tag(xtag) for xtag in ors)  for ors in self.ands)

my tags works:

  1. specifing product and version tags (eap, eap6.4)
  2. specifing optional openshift tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment