Esempio n. 1
0
def test_syntax_error_for_scenarios_with_no_name():
    ("Trying to parse features with unnamed "
     "scenarios will cause a syntax error")
    with pytest.raises(AloeSyntaxError) as error:
        Feature.from_string(FEATURE20)

    assert str(error.value) == ("Syntax error at: None\n"
                                "3:5 Scenario must have a name")
Esempio n. 2
0
def test_syntax_error_for_scenarios_with_no_name():
    ("Trying to parse features with unnamed "
     "scenarios will cause a syntax error")
    with assert_raises(AloeSyntaxError) as error:
        Feature.from_string(FEATURE20)

    assert_equal(error.exception.msg, "Syntax error at: None\n"
                 "3:5 Scenario must have a name")
Esempio n. 3
0
def test_syntax_error_for_scenarios_with_no_name():
    ("Trying to parse features with unnamed "
     "scenarios will cause a syntax error")
    with assert_raises(LettuceSyntaxError) as error:
        Feature.from_string(FEATURE20)

    assert error.exception.msg == \
        'Syntax error at: None\n' \
        '3:5 Scenario must have a name'
Esempio n. 4
0
def test_feature_max_length_on_scenario_outline_keys():
    """
    The max length of a feature considering when the table keys of the
    scenario oulines are longer than the remaining things
    """

    feature1 = Feature.from_string(FEATURE8)
    feature2 = Feature.from_string(FEATURE9)
    assert_equal(feature1.max_length, 68)
    assert_equal(feature2.max_length, 68)
Esempio n. 5
0
def test_feature_max_length_on_scenario_outline_keys():
    """
    The max length of a feature considering when the table keys of the
    scenario oulines are longer than the remaining things
    """

    feature1 = Feature.from_string(FEATURE8)
    feature2 = Feature.from_string(FEATURE9)
    assert_equal(feature1.max_length, 68)
    assert_equal(feature2.max_length, 68)
Esempio n. 6
0
def test_syntax_error_malformed_feature():
    """Parsing a malformed feature causes a syntax error."""

    with assert_raises(AloeSyntaxError) as error:
        Feature.from_string("""
PARSE ERROR
""")

    # pylint:disable=line-too-long
    assert_equal(error.exception.msg, '\n'.join((
        "Syntax error at: None",
        "Parser errors:",
        "(2:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'PARSE ERROR'",
    )))
Esempio n. 7
0
def test_syntax_error_malformed_feature():
    """Parsing a malformed feature causes a syntax error."""

    with pytest.raises(AloeSyntaxError) as error:
        Feature.from_string("""
PARSE ERROR
""")

    # pylint:disable=line-too-long
    assert str(error.value) == "\n".join((
        "Syntax error at: None",
        "Parser errors:",
        "(2:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'PARSE ERROR'",
    ))
Esempio n. 8
0
def test_outline_steps():
    """Test steps that are part of an outline."""

    feature = Feature.from_string(FEATURE6)

    # Steps that are a part of an outline have a reference back to the outline
    for outline, steps in feature.scenarios[0].evaluated:
        for step in steps:
            assert_equal(step.outline, outline)

    feature = Feature.from_string(FEATURE1)

    # Steps that are not a part of an outline don't have the outline reference
    for outline, steps in feature.scenarios[0].evaluated:
        for step in steps:
            assert_equal(step, outline, None)
Esempio n. 9
0
def test_outline_steps():
    """Test steps that are part of an outline."""

    feature = Feature.from_string(FEATURE6)

    # Steps that are a part of an outline have a reference back to the outline
    for outline, steps in feature.scenarios[0].evaluated:
        for step in steps:
            assert_equal(step.outline, outline)

    feature = Feature.from_string(FEATURE1)

    # Steps that are not a part of an outline don't have the outline reference
    for outline, steps in feature.scenarios[0].evaluated:
        for step in steps:
            assert_equal(step, outline, None)
Esempio n. 10
0
    def from_file(cls, file_):
        """
        Construct a test class from a feature file.
        """

        feature = Feature.from_file(
            file_,
            parser_class=TestGherkin,
        )

        background = cls.make_background(feature.background)
        scenarios = [
            cls.make_scenario(scenario, i + 1)
            for i, scenario in enumerate(feature.scenarios)
        ]

        before_feature, after_feature = \
            CALLBACK_REGISTRY.before_after('feature')

        members = {
            'feature': feature,
            'background': background,
            'before_feature': staticmethod(before_feature),
            'after_feature': staticmethod(after_feature),
        }

        members.update({
            scenario.__name__: scenario
            for scenario in scenarios
        })

        class_name = always_str(feature.name)

        return type(class_name, (cls,), members)
Esempio n. 11
0
    def from_file(cls, file_):
        """
        Construct a test class from a feature file.
        """

        feature = Feature.from_file(
            file_,
            parser_class=TestGherkin,
        )

        background = cls.make_background(feature.background)
        scenarios = [
            cls.make_scenario(scenario, i + 1)
            for i, scenario in enumerate(feature.scenarios)
        ]

        before_feature, after_feature = \
            CALLBACK_REGISTRY.before_after('feature')

        members = {
            'feature': feature,
            'background': background,
            'before_feature': staticmethod(before_feature),
            'after_feature': staticmethod(after_feature),
        }

        members.update({scenario.__name__: scenario for scenario in scenarios})

        class_name = always_str(feature.name)

        return type(class_name, (cls, ), members)
def test_feature_ptbr_from_string():
    """
    Language: PT-BR -> Feature.from_string
    """

    feature = Feature.from_string(FEATURE, language="pt-br")

    assert feature.name == "Pesquisar alunos com matrícula vencida"

    assert feature.description == (
        "Como gerente financeiro\n"
        "Eu quero pesquisar alunos com matrícula vencida\n"
        "Para propor um financiamento")

    (scenario, ) = feature.scenarios

    assert scenario.name == "Pesquisar por nome do curso"

    assert scenario.steps[-1].hashes == (
        {
            "nome": "João",
            "valor devido": "R$ 512,66"
        },
        {
            "nome": "Maria",
            "valor devido": "R$ 998,41"
        },
        {
            "nome": "Ana",
            "valor devido": "R$ 231,00"
        },
    )
Esempio n. 13
0
def test_background_parsing_without_mmf():
    """Test background parsing without description."""
    feature = Feature.from_string(FEATURE17)
    assert feature.description == ""

    assert isinstance(feature.background, Background)
    assert feature.background.steps
    assert len(feature.background.steps) == 2

    step1, step2 = feature.background.steps
    assert step1.sentence == "Given I have the following movies in my database:"
    assert step1.hashes == (
        {
            "Available": "6",
            "Rating": "4 stars",
            "Name": "Matrix Revolutions",
            "New": "no",
        },
        {
            "Available": "11",
            "Rating": "5 stars",
            "Name": "Iron Man 2",
            "New": "yes"
        },
    )
    assert step1.table == (
        ("Name", "Rating", "New", "Available"),
        ("Matrix Revolutions", "4 stars", "no", "6"),
        ("Iron Man 2", "5 stars", "yes", "11"),
    )

    assert step2.sentence == "And the following clients:"
    assert step2.hashes == ({"Name": "John Doe"}, {"Name": "Foo Bar"})
    assert step2.table == (("Name", ), ("John Doe", ), ("Foo Bar", ))
Esempio n. 14
0
def test_background_parsing_with_mmf():
    """Test background parsing with description."""
    feature = Feature.from_string(FEATURE16)
    assert (feature.description == "As a rental store owner\n"
            "I want to keep track of my clients\n"
            "So that I can manage my business better")

    assert isinstance(feature.background, Background)
    assert feature.background.steps
    assert len(feature.background.steps) == 2

    step1, step2 = feature.background.steps
    assert step1.sentence == "Given I have the following movies in my database:"
    assert step1.hashes == (
        {
            "Available": "6",
            "Rating": "4 stars",
            "Name": "Matrix Revolutions",
            "New": "no",
        },
        {
            "Available": "11",
            "Rating": "5 stars",
            "Name": "Iron Man 2",
            "New": "yes"
        },
    )

    assert step2.sentence == "And the following clients:"
    assert step2.hashes == ({"Name": "John Doe"}, {"Name": "Foo Bar"})
def test_scenario_outlines_within_feature():
    """
    Solving scenario outlines within a feature
    """

    feature = Feature.from_string(OUTLINED_FEATURE)
    scenario = feature.scenarios[0]
    solved = solved_steps(scenario)

    assert len(solved) == 12
    expected_sentences = [
        "Given I have entered 20 into the calculator",
        "And I have entered 30 into the calculator",
        "When I press add",
        "Then the result should be 50 on the screen",
        "Given I have entered 2 into the calculator",
        "And I have entered 5 into the calculator",
        "When I press add",
        "Then the result should be 7 on the screen",
        "Given I have entered 0 into the calculator",
        "And I have entered 40 into the calculator",
        "When I press add",
        "Then the result should be 40 on the screen",
    ]

    for step, expected in zip(solved, expected_sentences):
        assert type(step) == Step
        assert step.sentence == expected
Esempio n. 16
0
def test_scenarios_with_special_characters():
    "Make sure that regex special characters in the scenario names are ignored"
    feature = Feature.from_string(FEATURE19)

    assert feature.scenarios[0].tags == ['runme1']

    assert feature.scenarios[1].tags == ['runme2']
Esempio n. 17
0
def test_feature_ptbr_from_string():
    """
    Language: PT-BR -> Feature.from_string
    """

    feature = Feature.from_string(FEATURE, language='pt-br')

    assert_equal(feature.name, u'Pesquisar alunos com matrícula vencida')

    assert_equal(
        feature.description, u"Como gerente financeiro\n"
        u"Eu quero pesquisar alunos com matrícula vencida\n"
        u"Para propor um financiamento")

    (scenario, ) = feature.scenarios

    assert_equal(scenario.name, 'Pesquisar por nome do curso')

    assert_equal(scenario.steps[-1].hashes, (
        {
            'nome': u'João',
            u'valor devido': 'R$ 512,66'
        },
        {
            'nome': u'Maria',
            u'valor devido': 'R$ 998,41'
        },
        {
            'nome': u'Ana',
            u'valor devido': 'R$ 231,00'
        },
    ))
Esempio n. 18
0
def test_feature_first_scenario_tags_extraction():
    ("A feature object should be able to find the tags "
     "belonging to the first scenario")
    feature = Feature.from_string(FEATURE23)

    assert feature.scenarios[0].tags == \
        ['onetag', 'another', '$%^&even-weird_chars']
Esempio n. 19
0
def test_feature_first_scenario_tags_extraction():
    ("A feature object should be able to find the tags "
     "belonging to the first scenario")
    feature = Feature.from_string(FEATURE23)

    assert feature.scenarios[0].tags == \
        ('onetag', 'another', '$%^&even-weird_chars')
Esempio n. 20
0
def test_feature_ru_from_string():
    """
    Language: RU -> Feature.from_string
    """

    feature = Feature.from_string(FEATURE, language='ru')

    assert_equal(
        feature.name,
        u'Деление чисел'
    )

    assert_equal(
        feature.description,
        u"Поскольку деление сложный процесс и люди часто допускают ошибки\n"
        u"Нужно дать им возможность делить на калькуляторе"
    )

    (scenario, ) = feature.scenarios

    assert_equal(
        scenario.name,
        u'Целочисленное деление'
    )

    assert_equal(
        scenario.steps[-1].hashes,
        (
            {u'делимое': '100', u'делитель': '2', u'частное': '50'},
            {u'делимое': '28', u'делитель': '7', u'частное': '4'},
            {u'делимое': '0', u'делитель': '5', u'частное': '0'},
        )
    )
Esempio n. 21
0
def test_feature_fr_from_string2():
    """
    Language: FR -> Feature.from_string, alternate name
    """

    lang = Language("fr")

    feature = Feature.from_string(OUTLINED_FEATURE2, language=lang)

    assert_equal(feature.name, "Faire plusieur choses en même temps")

    assert_equal(
        feature.description,
        "De façon à automatiser les tests\n" "En tant que fainéant\n" "J'utilise les plans de scénario",
    )

    (scenario,) = feature.scenarios

    assert_equal(scenario.name, "Ajouter 2 nombres")

    assert_equal(
        scenario.outlines,
        [
            {"input_1": "20", "input_2": "30", "bouton": "add", "output": "50"},
            {"input_1": "2", "input_2": "5", "bouton": "add", "output": "7"},
            {"input_1": "0", "input_2": "40", "bouton": "add", "output": "40"},
        ],
    )
def test_feature_ru_from_string():
    """
    Language: RU -> Feature.from_string
    """

    feature = Feature.from_string(FEATURE, language='ru')

    assert_equal(
        feature.name,
        u'Деление чисел'
    )

    assert_equal(
        feature.description,
        u"Поскольку деление сложный процесс и люди часто допускают ошибки\n"
        u"Нужно дать им возможность делить на калькуляторе"
    )

    (scenario, ) = feature.scenarios

    assert_equal(
        scenario.name,
        u'Целочисленное деление'
    )

    assert_equal(
        scenario.steps[-1].hashes,
        (
            {u'делимое': '100', u'делитель': '2', u'частное': '50'},
            {u'делимое': '28', u'делитель': '7', u'частное': '4'},
            {u'делимое': '0', u'делитель': '5', u'частное': '0'},
        )
    )
Esempio n. 23
0
def test_can_parse_feature_description():
    """
    A feature object should have a description
    """

    feature = Feature.from_string(FEATURE2)

    assert_equal(
        feature.description,
        "In order to avoid silly mistakes\n"
        "Cashiers must be able to calculate a fraction"
    )
    expected_scenario_names = ["Regular numbers"]
    got_scenario_names = [s.name for s in feature.scenarios]

    assert_equal(expected_scenario_names, got_scenario_names)
    assert_equal(len(feature.scenarios[0].steps), 4)

    step1, step2, step3, step4 = feature.scenarios[0].steps

    assert_equal(step1.sentence, 'Given I have entered 3 into the calculator')
    assert_equal(step2.sentence, 'And I have entered 2 into the calculator')
    assert_equal(step3.sentence, 'When I press divide')
    assert_equal(step4.sentence,
                 'Then the result should be 1.5 on the screen')
Esempio n. 24
0
def test_scenarios_parsed_by_feature_has_feature():
    "Scenarios parsed by features has feature"

    feature = Feature.from_string(FEATURE2)

    for scenario in feature.scenarios:
        assert_equal(scenario.feature, feature)
Esempio n. 25
0
def test_scenario_outlines_within_feature():
    """
    Solving scenario outlines within a feature
    """

    feature = Feature.from_string(OUTLINED_FEATURE)
    scenario = feature.scenarios[0]
    solved = solved_steps(scenario)

    assert_equal(len(solved), 12)
    expected_sentences = [
        'Given I have entered 20 into the calculator',
        'And I have entered 30 into the calculator',
        'When I press add',
        'Then the result should be 50 on the screen',
        'Given I have entered 2 into the calculator',
        'And I have entered 5 into the calculator',
        'When I press add',
        'Then the result should be 7 on the screen',
        'Given I have entered 0 into the calculator',
        'And I have entered 40 into the calculator',
        'When I press add',
        'Then the result should be 40 on the screen',
    ]

    for step, expected in zip(solved, expected_sentences):
        assert_equal(type(step), Step)
        assert_equal(step.sentence, expected)
Esempio n. 26
0
def test_feature_ptbr_from_string():
    """
    Language: PT-BR -> Feature.from_string
    """

    ptbr = Language('pt-br')
    feature = Feature.from_string(FEATURE, language=ptbr)

    assert_equal(
        feature.name,
        u'Pesquisar alunos com matrícula vencida'
    )

    assert_equal(
        feature.description,
        u"Como gerente financeiro\n"
        u"Eu quero pesquisar alunos com matrícula vencida\n"
        u"Para propor um financiamento"
    )

    (scenario, ) = feature.scenarios

    assert_equal(
        scenario.name,
        'Pesquisar por nome do curso'
    )

    assert_equal(
        scenario.steps[-1].hashes,
        [
            {'nome': u'João', u'valor devido': 'R$ 512,66'},
            {'nome': u'Maria', u'valor devido': 'R$ 998,41'},
            {'nome': u'Ana', u'valor devido': 'R$ 231,00'},
        ]
    )
Esempio n. 27
0
def test_scenario_outlines_within_feature():
    """
    Solving scenario outlines within a feature
    """

    feature = Feature.from_string(OUTLINED_FEATURE)
    scenario = feature.scenarios[0]
    solved = solved_steps(scenario)

    assert_equal(len(solved), 12)
    expected_sentences = [
        'Given I have entered 20 into the calculator',
        'And I have entered 30 into the calculator',
        'When I press add',
        'Then the result should be 50 on the screen',
        'Given I have entered 2 into the calculator',
        'And I have entered 5 into the calculator',
        'When I press add',
        'Then the result should be 7 on the screen',
        'Given I have entered 0 into the calculator',
        'And I have entered 40 into the calculator',
        'When I press add',
        'Then the result should be 40 on the screen',
    ]

    for step, expected in zip(solved, expected_sentences):
        assert_equal(type(step), Step)
        assert_equal(step.sentence, expected)
Esempio n. 28
0
def test_scenarios_parsed_by_feature_has_feature():
    "Scenarios parsed by features has feature"

    feature = Feature.from_string(FEATURE2)

    for scenario in feature.scenarios:
        assert_equal(scenario.feature, feature)
Esempio n. 29
0
def test_scenarios_with_special_characters():
    "Make sure that regex special characters in the scenario names are ignored"
    feature = Feature.from_string(FEATURE19)

    assert feature.scenarios[0].tags == ('runme1',)

    assert feature.scenarios[1].tags == ('runme2',)
Esempio n. 30
0
def test_feature_max_length_on_feature_name():
    """
    The max length of a feature considering when the name of the feature
    is longer than the remaining things
    """

    feature = Feature.from_string(FEATURE3)
    assert_equal(feature.max_length, 78)
Esempio n. 31
0
def test_feature_max_length_on_feature_description():
    """
    The max length of a feature considering when one of the description lines
    of the feature is longer than the remaining things
    """

    feature = Feature.from_string(FEATURE2)
    assert_equal(feature.max_length, 47)
Esempio n. 32
0
def test_feature_max_length_on_scenario():
    """
    The max length of a feature considering when the scenario is longer than
    the remaining things
    """

    feature = Feature.from_string(FEATURE1)
    assert_equal(feature.max_length, 76)
Esempio n. 33
0
def test_feature_max_length_on_scenario_outline():
    """
    The max length of a feature considering when the table of some of the
    scenario oulines is longer than the remaining things
    """

    feature = Feature.from_string(FEATURE6)
    assert_equal(feature.max_length, 79)
Esempio n. 34
0
def test_description_on_long_named_feature():
    "Can parse the description on long named features"
    feature = Feature.from_string(FEATURE3)
    assert_equal(
        feature.description,
        "In order to describe my features\n"
        "I want to add description on them",
    )
Esempio n. 35
0
def test_feature_max_length_on_scenario_outline():
    """
    The max length of a feature considering when the table of some of the
    scenario oulines is longer than the remaining things
    """

    feature = Feature.from_string(FEATURE6)
    assert_equal(feature.max_length, 79)
Esempio n. 36
0
def test_feature_max_length_on_step_with_table():
    """
    The max length of a feature considering when the table of some of the steps
    is longer than the remaining things
    """

    feature = Feature.from_string(FEATURE5)
    assert feature.max_length == 83
Esempio n. 37
0
def test_comments():
    """
    It should ignore lines that start with #, despite white spaces
    """

    feature = Feature.from_string(FEATURE10)

    assert_equal(feature.max_length, 55)
Esempio n. 38
0
def test_description_on_long_named_feature():
    "Can parse the description on long named features"
    feature = Feature.from_string(FEATURE3)
    assert_equal(
        feature.description,
        "In order to describe my features\n"
        "I want to add description on them",
    )
Esempio n. 39
0
def test_feature_max_length_on_step_with_table_keys():
    """
    The max length of a feature considering when the table keys of some of the
    steps are longer than the remaining things
    """

    feature = Feature.from_string(FEATURE7)
    assert_equal(feature.max_length, 74)
Esempio n. 40
0
def test_comments():
    """
    It should ignore lines that start with #, despite white spaces
    """

    feature = Feature.from_string(FEATURE10)

    assert_equal(feature.max_length, 55)
Esempio n. 41
0
def test_single_scenario_single_scenario():
    "Features should have at least the first scenario parsed with tags"
    feature = Feature.from_string(FEATURE11)

    first_scenario = feature.scenarios[0]

    assert_equal(first_scenario.tags,
                 ('many', 'other', 'basic', 'tags', 'here', ':)'))
Esempio n. 42
0
def test_feature_max_length_on_step_sentence():
    """
    The max length of a feature considering when the some of the step sentences
    is longer than the remaining things
    """

    feature = Feature.from_string(FEATURE4)
    assert_equal(feature.max_length, 55)
Esempio n. 43
0
def test_feature_max_length_on_feature_description():
    """
    The max length of a feature considering when one of the description lines
    of the feature is longer than the remaining things
    """

    feature = Feature.from_string(FEATURE2)
    assert_equal(feature.max_length, 47)
Esempio n. 44
0
def test_feature_max_length_on_step_with_table_keys():
    """
    The max length of a feature considering when the table keys of some of the
    steps are longer than the remaining things
    """

    feature = Feature.from_string(FEATURE7)
    assert_equal(feature.max_length, 74)
Esempio n. 45
0
def test_feature_max_length_on_scenario():
    """
    The max length of a feature considering when the scenario is longer than
    the remaining things
    """

    feature = Feature.from_string(FEATURE1)
    assert_equal(feature.max_length, 76)
Esempio n. 46
0
def test_feature_max_length_on_feature_name():
    """
    The max length of a feature considering when the name of the feature
    is longer than the remaining things
    """

    feature = Feature.from_string(FEATURE3)
    assert_equal(feature.max_length, 78)
Esempio n. 47
0
def test_feature_max_length_on_step_sentence():
    """
    The max length of a feature considering when the some of the step sentences
    is longer than the remaining things
    """

    feature = Feature.from_string(FEATURE4)
    assert_equal(feature.max_length, 55)
Esempio n. 48
0
def test_single_scenario_single_scenario():
    "Features should have at least the first scenario parsed with tags"
    feature = Feature.from_string(FEATURE11)

    first_scenario = feature.scenarios[0]

    assert first_scenario.tags == ("many", "other", "basic", "tags", "here",
                                   ":)")
Esempio n. 49
0
def parse_scenario(string, language=None):
    """Parse a scenario, prefixing it with a feature header."""
    feature = u"""
    Функция: parse_scenario
    """
    feature += string
    feature = Feature.from_string(feature, language=language)

    return feature.scenarios[0]
Esempio n. 50
0
def test_syntax_error_malformed_feature_from_file():
    """Parsing a malformed feature in a filecauses a syntax error."""

    with tempfile.NamedTemporaryFile() as feature_file:
        feature_file.write(b"""
PARSE ERROR
""")
        feature_file.flush()

        with assert_raises(AloeSyntaxError) as error:
            Feature.from_file(feature_file.name)

        # pylint:disable=line-too-long
        assert_equal(error.exception.msg, '\n'.join((
            "Syntax error at: {filename}",
            "Parser errors:",
            "(2:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'PARSE ERROR'",
        )).format(filename=feature_file.name))
Esempio n. 51
0
def test_description_on_big_sentenced_steps():
    "Can parse the description on long sentenced steps"
    feature = Feature.from_string(FEATURE4)
    assert_equal(
        feature.description,
        "As a clever guy\n"
        "I want to describe this Feature\n"
        "So that I can take care of my Scenario",
    )
Esempio n. 52
0
def test_single_feature_single_tag():
    "All scenarios within a feature inherit the feature's tags"
    feature = Feature.from_string(FEATURE18)

    assert feature.scenarios[0].tags == ['runme1', 'feature_runme']

    assert feature.scenarios[1].tags == ['runme2', 'feature_runme']

    assert feature.scenarios[2].tags == ['runme3', 'feature_runme']
Esempio n. 53
0
def parse_scenario(string, language=None):
    """Parse a scenario, prefixing it with a feature header."""
    feature_str = u"""
    Функция: parse_scenario
    """
    feature_str += string
    feature = Feature.from_string(feature_str, language=language)

    return feature.scenarios[0]
Esempio n. 54
0
def test_description_on_big_sentenced_steps():
    "Can parse the description on long sentenced steps"
    feature = Feature.from_string(FEATURE4)
    assert_equal(
        feature.description,
        "As a clever guy\n"
        "I want to describe this Feature\n"
        "So that I can take care of my Scenario",
    )
Esempio n. 55
0
def test_single_scenario_single_scenario():
    "Features should have at least the first scenario parsed with tags"
    feature = Feature.from_string(FEATURE11)

    first_scenario = feature.scenarios[0]

    assert_equal(first_scenario.tags, (
        'many', 'other', 'basic', 'tags', 'here', ':)'
    ))
Esempio n. 56
0
def test_single_feature_single_tag():
    "All scenarios within a feature inherit the feature's tags"
    feature = Feature.from_string(FEATURE18)

    assert feature.scenarios[0].tags == ('runme1', 'feature_runme')

    assert feature.scenarios[1].tags == ('runme2', 'feature_runme')

    assert feature.scenarios[2].tags == ('runme3', 'feature_runme')
Esempio n. 57
0
def parse_steps(step):
    """Parse a step, prefixing it with a feature and a scenario header."""
    feature = """
    Feature: parse a step
    Scenario: parse a single step
    """

    feature += step

    return Feature.from_string(feature).scenarios[0].steps
Esempio n. 58
0
def parse_scenario(string, language=None):
    """Parse a scenario, prefixing it with a feature header."""
    feature = """
Funcionalidade: parse_scenario
    """

    feature += string
    feature = Feature.from_string(feature, language=language)

    return feature.scenarios[0]
Esempio n. 59
0
def test_scenario_has_name():
    """
    It should extract the name string from the scenario
    """

    feature = Feature.from_string(FEATURE1)

    assert isinstance(feature, Feature)

    assert feature.name == "Rent movies"
Esempio n. 60
0
def test_scenario_post_email():
    ("Having a scenario which the body has an email address; "
     "Then the following scenario should have no "
     "tags related to the email")

    feature = Feature.from_string(FEATURE21)
    scenario1, scenario2 = feature.scenarios

    assert scenario1.tags == ()
    assert scenario2.tags == ('tag',)