예제 #1
0
def test_scenariooutline_example_invalid_colum_width():
    """
    Test invalid column id exception when calculating column width for Scenario Outline Examples
    """
    # given
    scenario_outline = ScenarioOutline(
        1,
        "Scenario Outline",
        "Examples",
        "I am a Scenario Outline",
        "foo.feature",
        1,
        parent=None,
        tags=None,
        preconditions=None,
        background=None,
    )
    # add examples
    scenario_outline.examples_header = ["foo", "bar"]
    scenario_outline.examples = [
        # row 0
        ScenarioOutline.Example(["Spiderman", "Batman"], "foo.feature", 1),
        # row 3
        ScenarioOutline.Example(["Peter", "Bruce Wayne"], "foo.feature", 2),
    ]

    # when
    with pytest.raises(RadishError) as exc:
        scenario_outline.get_column_width(42)

    # then
    assert (
        str(exc.value)
        == "Invalid colum_index to get column width for ScenarioOutline 'I am a Scenario Outline'"
    )
예제 #2
0
def test_scenariooutline_example_invalid_colum_width():
    """
    Test invalid column id exception when calculating column width for Scenario Outline Examples
    """
    # given
    scenario_outline = ScenarioOutline(1,
                                       'Scenario Outline',
                                       'Examples',
                                       'I am a Scenario Outline',
                                       'foo.feature',
                                       1,
                                       parent=None,
                                       tags=None,
                                       preconditions=None,
                                       background=None)
    # add examples
    scenario_outline.examples_header = ['foo', 'bar']
    scenario_outline.examples = [
        # row 0
        ScenarioOutline.Example(['Spiderman', 'Batman'], 'foo.feature', 1),
        # row 3
        ScenarioOutline.Example(['Peter', 'Bruce Wayne'], 'foo.feature', 2),
    ]

    # when
    with pytest.raises(RadishError) as exc:
        scenario_outline.get_column_width(42)

    # then
    assert str(
        exc.value
    ) == "Invalid colum_index to get column width for ScenarioOutline 'I am a Scenario Outline'"
예제 #3
0
def test_scenariooutline_example_colum_width():
    """
    Test calculation for maximum width of Example columns
    """
    # given
    scenario_outline = ScenarioOutline(
        1,
        "Scenario Outline",
        "Examples",
        "I am a Scenario Outline",
        "foo.feature",
        1,
        parent=None,
        tags=None,
        preconditions=None,
        background=None,
    )
    # add examples
    scenario_outline.examples_header = ["foo", "bar"]
    scenario_outline.examples = [
        # row 0
        ScenarioOutline.Example(["Spiderman", "Batman"], "foo.feature", 1),
        # row 3
        ScenarioOutline.Example(["Peter", "Bruce Wayne"], "foo.feature", 2),
    ]

    # when
    index_0_width = scenario_outline.get_column_width(0)
    # then
    assert index_0_width == len("Spiderman")

    # when
    index_1_width = scenario_outline.get_column_width(1)
    # then
    assert index_1_width == len("Bruce Wayne")
예제 #4
0
def test_scenariooutline_example_colum_width():
    """
    Test calculation for maximum width of Example columns
    """
    # given
    scenario_outline = ScenarioOutline(1,
                                       'Scenario Outline',
                                       'Examples',
                                       'I am a Scenario Outline',
                                       'foo.feature',
                                       1,
                                       parent=None,
                                       tags=None,
                                       preconditions=None,
                                       background=None)
    # add examples
    scenario_outline.examples_header = ['foo', 'bar']
    scenario_outline.examples = [
        # row 0
        ScenarioOutline.Example(['Spiderman', 'Batman'], 'foo.feature', 1),
        # row 3
        ScenarioOutline.Example(['Peter', 'Bruce Wayne'], 'foo.feature', 2),
    ]

    # when
    index_0_width = scenario_outline.get_column_width(0)
    # then
    assert index_0_width == len('Spiderman')

    # when
    index_1_width = scenario_outline.get_column_width(1)
    # then
    assert index_1_width == len('Bruce Wayne')