How to use the behave.model.Tag function in behave

To help you get started, we’ve selected a few behave examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github behave / behave / tests / unit / test_parser.py View on Github external
Then we have 

    Examples: Some stuff
      | Stuff      | Things   |
      | wool       | felt     |
      | cotton     | thread   |
      | wood       | paper    |
      | explosives | hilarity |
'''.lstrip()
        feature = parser.parse_feature(doc)
        assert feature.name == "Stuff"

        assert len(feature.scenarios) == 1
        assert feature.scenarios[0].name == "Doing all sorts of stuff"
        assert feature.scenarios[0].tags == [
            model.Tag(u'stuff', 1), model.Tag(u'derp', 1)
        ]
        assert_compare_steps(feature.scenarios[0].steps, [
            ('given', 'Given', 'we have ', None, None),
            ('when', 'When', 'we do stuff', None, None),
            ('then', 'Then', 'we have ', None, None),
        ])

        table = model.Table(
            [u'Stuff', u'Things'],
            0,
            [
                [u'wool', u'felt'],
                [u'cotton', u'thread'],
                [u'wood', u'paper'],
                [u'explosives', u'hilarity'],
            ]
github behave / behave / tests / unit / test_parser.py View on Github external
doc = u"""
@foo @bar @baz @qux @winkle_pickers # Comment: @number8
Feature: Stuff
  In order to thing
  As an entity
  I want to do stuff
""".strip()
        feature = parser.parse_feature(doc)
        assert feature.name == "Stuff"
        assert feature.description == [
            "In order to thing",
            "As an entity",
            "I want to do stuff"
        ]
        assert feature.tags == [
            model.Tag(name, 1)
            for name in (u'foo', u'bar', u'baz', u'qux', u'winkle_pickers')
        ]
github behave / behave / tests / unit / test_parser.py View on Github external
Given stuff
    Then who gives a stuff
""".lstrip()
        feature = parser.parse_feature(doc)
        assert feature.name == "Stuff"
        assert len(feature.scenarios) == 3

        assert feature.scenarios[0].name == "Doing stuff"
        assert_compare_steps(feature.scenarios[0].steps, [
            ('given', 'Given', 'there is stuff', None, None),
            ('when', 'When', 'I do stuff', None, None),
            ('then', 'Then', 'stuff happens', None, None),
        ])

        assert feature.scenarios[1].name == "Doing other stuff"
        assert feature.scenarios[1].tags == [model.Tag(u"one_tag", 1)]
        assert_compare_steps(feature.scenarios[1].steps, [
            ('when', 'When', 'stuff happens', None, None),
            ('then', 'Then', 'I am stuffed', None, None),
        ])

        assert feature.scenarios[2].name == "Doing different stuff"
        assert feature.scenarios[2].tags == [
            model.Tag(n, 1) for n in (u'lots', u'of', u'tags')]
        assert_compare_steps(feature.scenarios[2].steps, [
            ('given', 'Given', 'stuff', None, None),
            ('then', 'Then', 'who gives a stuff', None, None),
        ])
github behave / behave / tests / unit / test_parser.py View on Github external
def test_parses_feature_with_a_tag_and_comment(self):
        doc = u"""
@foo    # Comment: ...
Feature: Stuff
  In order to thing
  As an entity
  I want to do stuff
""".strip()
        feature = parser.parse_feature(doc)
        assert feature.name == "Stuff"
        assert feature.description == [
            "In order to thing",
            "As an entity",
            "I want to do stuff"
        ]
        assert feature.tags, [model.Tag(u'foo', 1)]
github behave / behave / tests / unit / test_model2.py View on Github external
def check_make_name(self, tag, expected):
        if expected is self.SAME_AS_TAG:
            expected = tag

        actual_name = Tag.make_name(tag, allowed_chars=Tag.allowed_chars)
        assert actual_name == expected
github behave / behave / tests / unit / test_parser.py View on Github external
table = model.Table(
            [u"Stuff", u"Things"], 0,
            [
                [u"wool", u"felt"],
                [u"cotton", u"thread"],
            ]
        )
        assert scenario_outline.examples[0].name == "Charly"
        assert scenario_outline.examples[0].table == table
        assert scenario_outline.examples[0].tags == [model.Tag(u"bar", 1)]

        # -- ScenarioOutline.scenarios:
        # Inherit tags from ScenarioOutline and Examples element.
        assert len(scenario_outline.scenarios) == 2
        expected_tags = [model.Tag(u"foo", 1), model.Tag(u"bar", 1)]
        assert set(scenario_outline.scenarios[0].tags) == set(expected_tags)
        assert set(scenario_outline.scenarios[1].tags), set(expected_tags)
github behave / behave / behave / parser.py View on Github external
def parse_tags(self, line):
        """Parse a line with one or more tags:

          * A tag starts with the AT sign.
          * A tag consists of one word without whitespace chars.
          * Multiple tags are separated with whitespace chars
          * End-of-line comment is stripped.

        :param line:   Line with one/more tags to process.
        :raise ParserError: If syntax error is detected.
        """
        assert line.startswith("@")
        tags = []
        for word in line.split():
            if word.startswith("@"):
                tags.append(model.Tag(word[1:], self.line))
            elif word.startswith("#"):
                break   # -- COMMENT: Skip rest of line.
            else:
                # -- BAD-TAG: Abort here.
                message = u"tag: %s (line: %s)" % (word, line)
                raise ParserError(message, self.line, self.filename)
        return tags