Example #1
0
    def represent_outlines(self):
        """
        Render the outlines table.
        """

        return strings.represent_table(
            self.outlines_table, indent=self.indent + 2)
Example #2
0
def example_wrapper(term, scenario, outline, steps):
    """Display scenario execution."""

    try:
        if scenario.tags:
            term.writeln(term.cyan(scenario.represent_tags()))

        start, end = scenario.represented().rsplit('#')
        term.write(term.bold_white(start))
        term.writeln(term.color(8)(end))

        if outline:
            term.writeln(
                represent_table(
                    [outline.keys(), outline.values()],
                    indent=6,
                    cell_wrap=term.white))
            term.writeln()

        # write a preview of the steps
        if term.is_a_tty:
            steps_ = []

            if scenario.feature.background:
                steps_ += scenario.feature.background.steps

            steps_ += steps

            term.writeln(term.color(8)('\n'.join(
                step.represented(annotate=False) for step in steps_) + '\n'),
                         return_=True)

        yield
    finally:
        term.writeln()
Example #3
0
    def represent_outlines(self):
        """
        Render the outlines table.
        """

        return strings.represent_table(self.outlines_table,
                                       indent=self.indent + 2)
def example_wrapper(term, scenario, outline, steps):
    """Display scenario execution."""

    try:
        if scenario.tags:
            term.writeln(term.tag(scenario.represent_tags()))

        represented = scenario.represented()
        represented = ljust(represented, scenario.feature.max_length + 2)

        term.write(represented)
        term.writeln(term.comment('# ' + scenario.location))

        if outline:
            term.writeln(
                represent_table(
                    [outline.keys(), outline.values()], indent=6))
            term.writeln()

        # write a preview of the steps
        if term.is_a_tty:
            steps_ = []

            if scenario.feature.background:
                steps_ += scenario.feature.background.steps

            steps_ += steps

            term.writeln(term.preview('\n'.join(step.represented()
                                                for step in steps_) + '\n'),
                         return_=True)

        yield
    finally:
        term.writeln()
Example #5
0
    def represent_table(self, **kwargs):
        """
        Render the table.

        :param cell_wrap: color to use inside the table cells
        """

        return strings.represent_table(self.table, indent=self.indent + 2, **kwargs)
Example #6
0
    def represent_table(self, **kwargs):
        """
        Render the table.

        :param cell_wrap: color to use inside the table cells
        """

        return strings.represent_table(
            self.table, indent=self.indent + 2, **kwargs)
Example #7
0
def test_represent_table():
    """
    Test representing a table
    """

    table = [
        ['name', 'age'],
        [u'Gabriel Falcão', 22],
        ['Miguel', 19],
    ]

    assert_equal(
        strings.represent_table(table), u"| name           | age |\n"
        u"| Gabriel Falcão | 22  |\n"
        u"| Miguel         | 19  |")
Example #8
0
def test_represent_table_allows_empty():
    """
    Test representing a table with an empty cell
    """

    table = [
        ['name', 'age'],
        [u'Gabriel | Falcão', 22],
        ['Miguel | Arcanjo', ''],
    ]

    assert_equal(
        strings.represent_table(table), '\n'.join((
            r"| name              | age |",
            r"| Gabriel \| Falcão | 22  |",
            r"| Miguel \| Arcanjo |     |",
        )))
Example #9
0
def test_represent_table_escapes_pipe():
    """
    Test representing a table with escaping
    """

    table = [
        ['name', 'age'],
        [u'Gabriel | Falcão', 22],
        ['Miguel | Arcanjo', 19],
    ]

    assert_equal(
        strings.represent_table(table), '\n'.join((
            r"| name              | age |",
            r"| Gabriel \| Falcão | 22  |",
            r"| Miguel \| Arcanjo | 19  |",
        )))
Example #10
0
def test_represent_table():
    """
    Test representing a table
    """

    table = [
        ['name', 'age'],
        [u'Gabriel Falcão', 22],
        ['Miguel', 19],
    ]

    assert_equal(
        strings.represent_table(table),
        u"| name           | age |\n"
        u"| Gabriel Falcão | 22  |\n"
        u"| Miguel         | 19  |"
    )
Example #11
0
def test_represent_table_allows_empty():
    """
    Test representing a table with an empty cell
    """

    table = [
        ['name', 'age'],
        [u'Gabriel | Falcão', 22],
        ['Miguel | Arcanjo', ''],
    ]

    assert_equal(
        strings.represent_table(table),
        '\n'.join((
            r"| name              | age |",
            r"| Gabriel \| Falcão | 22  |",
            r"| Miguel \| Arcanjo |     |",
        ))
    )
Example #12
0
def test_represent_table_escapes_pipe():
    """
    Test representing a table with escaping
    """

    table = [
        ['name', 'age'],
        [u'Gabriel | Falcão', 22],
        ['Miguel | Arcanjo', 19],
    ]

    assert_equal(
        strings.represent_table(table),
        '\n'.join((
            r"| name              | age |",
            r"| Gabriel \| Falcão | 22  |",
            r"| Miguel \| Arcanjo | 19  |",
        ))
    )
Example #13
0
def example_wrapper(term, scenario, outline, steps):
    """Display scenario execution."""

    try:
        if scenario.tags:
            term.writeln(term.cyan(scenario.represent_tags()))

        represented = scenario.represented()
        represented = ljust(represented, scenario.feature.max_length + 2)

        term.write(term.bold_white(represented))
        term.writeln(term.color(8)(scenario.location))

        if outline:
            term.writeln(represent_table([outline.keys(),
                                          outline.values()],
                                         indent=6,
                                         cell_wrap=term.white))
            term.writeln()

        # write a preview of the steps
        if term.is_a_tty:
            steps_ = []

            if scenario.feature.background:
                steps_ += scenario.feature.background.steps

            steps_ += steps

            term.writeln(
                term.color(8)('\n'.join(
                    step.represented()
                    for step in steps_
                ) + '\n'),
                return_=True
            )

        yield
    finally:
        term.writeln()
Example #14
0
def example_wrapper(term, scenario, outline, steps):
    """Display scenario execution."""

    try:
        if scenario.tags:
            term.writeln(term.cyan(scenario.represent_tags()))

        start, end = scenario.represented().rsplit('#')
        term.write(term.bold_white(start))
        term.writeln(term.color(8)(end))

        if outline:
            term.writeln(represent_table([outline.keys(),
                                          outline.values()],
                                         indent=6,
                                         cell_wrap=term.white))
            term.writeln()

        # write a preview of the steps
        if term.is_a_tty:
            steps_ = []

            if scenario.feature.background:
                steps_ += scenario.feature.background.steps

            steps_ += steps

            term.writeln(
                term.color(8)('\n'.join(
                    step.represented(annotate=False)
                    for step in steps_
                ) + '\n'),
                return_=True
            )

        yield
    finally:
        term.writeln()