本文整理汇总了Python中aloe.parser.Feature类的典型用法代码示例。如果您正苦于以下问题:Python Feature类的具体用法?Python Feature怎么用?Python Feature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Feature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_syntax_error_for_scenarios_with_no_name
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'
示例2: test_feature_max_length_on_scenario_outline_keys
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)
示例3: test_syntax_error_malformed_feature
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'",
)))
示例4: test_outline_steps
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)
示例5: test_scenario_outlines_within_feature
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)
示例6: test_scenarios_parsed_by_feature_has_feature
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)
示例7: test_can_parse_feature_description
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')
示例8: test_feature_ru_from_string
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'},
)
)
示例9: test_feature_fr_from_string2
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"},
],
)
示例10: test_feature_first_scenario_tags_extraction
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')
示例11: test_scenarios_with_special_characters
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',)
示例12: test_feature_ptbr_from_string
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'},
]
)
示例13: from_file
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)
示例14: test_feature_max_length_on_scenario_outline
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)
示例15: test_comments
def test_comments():
"""
It should ignore lines that start with #, despite white spaces
"""
feature = Feature.from_string(FEATURE10)
assert_equal(feature.max_length, 55)