How to use the behave.model.Table 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
| Stuff      | Things   |
      | wool       | felt     |
      | cotton     | thread   |
'''.lstrip()
        feature = parser.parse_feature(doc)
        assert feature.name == "Alice"

        assert len(feature.scenarios) == 1
        scenario_outline = feature.scenarios[0]
        assert scenario_outline.name == "Bob"
        assert scenario_outline.tags == [model.Tag(u"foo", 1)]
        assert_compare_steps(scenario_outline.steps, [
            ("given", "Given", "we have ", None, None),
        ])

        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 / tests / unit / test_parser.py View on Github external
| Stuff      | Things   |
      | 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_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'],
            ]
        )
        assert feature.scenarios[0].examples[0].name == "Some stuff"
        assert feature.scenarios[0].examples[0].table == table

        table = model.Table(
            [u'Stuff', u'Things'],
            0,
            [
                [u'wood', u'paper'],
                [u'explosives', u'hilarity'],
github behave / behave / behave / json_parser.py View on Github external
def parse_table(self, json_table):
        """
        table_data = {
            'headings': table.headings,
            'rows': [ list(row) for row in table.rows ]
        }
        return table_data
        """
        headings = json_table.get("headings", [])
        rows    = json_table.get("rows", [])
        table = model.Table(headings, rows=rows)
        return table
github tinyerp / openobject-mirliton / features / support / behave_better.py View on Github external
def patch_model_Table_raw():
    # Add attribute Table.raw
    def raw(self):
        yield list(self.headings)
        for row in self.rows:
            yield list(row)
    model.Table.raw = property(raw)
github behave / behave / behave / model.py View on Github external
def __eq__(self, other):
        if isinstance(other, Table):
            if self.headings != other.headings:
                return False
            for my_row, their_row in zip(self.rows, other.rows):
                if my_row != their_row:
                    return False
        else:
            # -- ASSUME: table <=> raw data comparison
            other_rows = other
            for my_row, their_row in zip(self.rows, other_rows):
                if my_row != their_row:
                    return False
        return True
github behave / behave / behave / formatter / sphinx_steps.py View on Github external
def write_step_module_overview(self, step_definitions):
        assert self.document
        headings = [u"Step Definition", u"Given", u"When", u"Then", u"Step"]
        table = Table(headings)
        step_type_cols = {
            # -- pylint: disable=bad-whitespace
            "given": [u"  x", u"  ",  u"  ",  u"  "],
            "when":  [u"  ",  u"  x", u"  ",  u"  "],
            "then":  [u"  ",  u"  ",  u"  x", u"  "],
            "step":  [u"  x", u"  x", u"  x", u"  x"],
        }
        for step_definition in step_definitions:
            row = [self.describe_step_definition(step_definition)]
            row.extend(step_type_cols[step_definition.step_type])
            table.add_row(row)
        self.document.write_table(table)