本文整理汇总了Python中pyccuracy.parsers.FileParser类的典型用法代码示例。如果您正苦于以下问题:Python FileParser类的具体用法?Python FileParser怎么用?Python FileParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileParser类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_parsing_folder_with_no_stories_returns_empty_list
def test_parsing_folder_with_no_stories_returns_empty_list():
settings = Settings()
settings.tests_dirs = [abspath(join(dirname(__file__), "no_stories_folder"))]
parser = FileParser()
fixture = parser.get_stories(settings=settings)
assert len(fixture.stories) == 0
开发者ID:Desperado,项目名称:pyccuracy,代码行数:7,代码来源:test_file_parser.py
示例2: test_parsing_files_with_empty_content_returns_invalid_files_list
def test_parsing_files_with_empty_content_returns_invalid_files_list():
mocker = Mocker()
settings = Settings()
files = ["some path"]
story_text = ""
filemock = mocker.mock()
filemock.list_files(directories=settings.tests_dirs, pattern=settings.file_pattern)
mocker.result(files)
filemock.read_file(files[0])
mocker.result(story_text)
language_mock = mocker.mock()
language_mock.get("as_a")
mocker.result("As a")
language_mock.get("i_want_to")
mocker.result("I want to")
language_mock.get("so_that")
mocker.result("So that")
language_mock.get("no_header_failure")
mocker.result("No header found")
with mocker:
parser = FileParser(language=language_mock, file_object=filemock)
fixture = parser.get_stories(settings=settings)
assert len(fixture.no_story_header) == 1
file_path = fixture.no_story_header[0]
assert file_path == "some path"
开发者ID:Desperado,项目名称:pyccuracy,代码行数:32,代码来源:test_file_parser.py
示例3: test_parsing_files_with_many_scenarios_returns_parsed_scenarios
def test_parsing_files_with_many_scenarios_returns_parsed_scenarios():
class DoSomethingAction(ActionBase):
regex = r'I do something$'
def execute(context, *args, **kwargs):
pass
class DoSomethingElseAction(ActionBase):
regex = r'I do something else$'
def execute(context, *args, **kwargs):
pass
class DoYetAnotherThingAction(ActionBase):
regex = r'I do yet another thing$'
def execute(context, *args, **kwargs):
pass
settings = Settings()
settings.tests_dirs = [abspath(dirname(__file__))]
settings.file_pattern = "some_test.acc"
parser = FileParser()
fixture = parser.get_stories(settings=settings)
assert_no_invalid_stories(fixture)
assert len(fixture.stories) == 1, "Expected 1, Actual: %d" % len(fixture.stories)
assert len(fixture.stories[0].scenarios) == 2
assert "#some custom comment" in fixture.stories[0].scenarios[1].whens[0].description
开发者ID:Desperado,项目名称:pyccuracy,代码行数:29,代码来源:test_file_parser.py
示例4: test_parsing_files_with_proper_header_returns_parsed_scenario
def test_parsing_files_with_proper_header_returns_parsed_scenario():
mocker = Mocker()
settings = Settings()
files = ["some path"]
story_text = """As a someone
I want to do something
So that I'm happy"""
filemock = mocker.mock()
filemock.list_files(directories=settings.tests_dirs, pattern=settings.file_pattern)
mocker.result(files)
filemock.read_file(files[0])
mocker.result(story_text)
language_mock = mocker.mock()
language_mock.get("as_a")
mocker.result("As a")
language_mock.get("i_want_to")
mocker.result("I want to")
language_mock.get("so_that")
mocker.result("So that")
with mocker:
parser = FileParser(language=language_mock, file_object=filemock)
fixture = parser.get_stories(settings=settings)
assert len(fixture.stories) == 1
assert fixture.stories[0].as_a == "someone"
assert fixture.stories[0].i_want_to == "do something"
assert fixture.stories[0].so_that == "I'm happy"
开发者ID:Desperado,项目名称:pyccuracy,代码行数:33,代码来源:test_file_parser.py
示例5: test_parsing_stories_returns_list
def test_parsing_stories_returns_list():
settings = Settings()
filemock = Mock()
filemock.expects(once()) \
.list_files(directories=same(settings.tests_dirs), pattern=same(settings.file_pattern)) \
.will(return_value([]))
parser = FileParser(file_object=filemock)
fixture = parser.get_stories(settings=settings)
assert isinstance(fixture, Fixture)
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:10,代码来源:test_file_parser.py
示例6: test_is_not_keyword
def test_is_not_keyword():
language_mock = Mock()
language_mock.expects(once()) \
.get(eq("keyword")) \
.will(return_value("kw"))
parser = FileParser(language=language_mock, file_object=None)
is_keyword = parser.is_keyword("other", "keyword")
assert not is_keyword
language_mock.verify()
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:11,代码来源:test_file_parser.py
示例7: test_is_not_scenario_starter_line
def test_is_not_scenario_starter_line():
language_mock = Mock()
language_mock.expects(once()) \
.get(eq("scenario")) \
.will(return_value("Scenario"))
parser = FileParser(language=language_mock, file_object=None)
is_scenario_starter_line = parser.is_scenario_starter_line("Cenario bla")
assert not is_scenario_starter_line
language_mock.verify()
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:11,代码来源:test_file_parser.py
示例8: test_parsing_files_with_wrong_so_that_returns_no_story_header_list
def test_parsing_files_with_wrong_so_that_returns_no_story_header_list():
settings = Settings()
settings.tests_dirs = [abspath(join(dirname(__file__), "invalid_content_stories"))]
settings.file_pattern = "invalid_so_that.acc"
parser = FileParser()
fixture = parser.get_stories(settings=settings)
assert len(fixture.no_story_header) == 1
file_path = fixture.no_story_header[0]
assert file_path.endswith("invalid_so_that.acc")
开发者ID:Desperado,项目名称:pyccuracy,代码行数:12,代码来源:test_file_parser.py
示例9: test_parsing_folder_with_no_stories_returns_empty_list
def test_parsing_folder_with_no_stories_returns_empty_list():
settings = Settings()
files = []
filemock = Mock()
filemock.expects(once()) \
.list_files(directories=same(settings.tests_dirs), pattern=same(settings.file_pattern)) \
.will(return_value(files))
parser = FileParser(file_object=filemock)
fixture = parser.get_stories(settings=settings)
assert len(fixture.stories) == 0
filemock.verify()
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:13,代码来源:test_file_parser.py
示例10: test_is_not_scenario_starter_line
def test_is_not_scenario_starter_line():
mocker = Mocker()
language_mock = mocker.mock()
language_mock.get("scenario")
mocker.result("Scenario")
with mocker:
parser = FileParser(language=language_mock, file_object=None)
is_scenario_starter_line = parser.is_scenario_starter_line("Cenario bla")
assert not is_scenario_starter_line
开发者ID:Desperado,项目名称:pyccuracy,代码行数:13,代码来源:test_file_parser.py
示例11: test_is_not_keyword
def test_is_not_keyword():
mocker = Mocker()
language_mock = mocker.mock()
language_mock.get("keyword")
mocker.result("kw")
with mocker:
parser = FileParser(language=language_mock, file_object=None)
is_keyword = parser.is_keyword("other", "keyword")
assert not is_keyword
开发者ID:Desperado,项目名称:pyccuracy,代码行数:13,代码来源:test_file_parser.py
示例12: test_parsing_stories_returns_list
def test_parsing_stories_returns_list():
mocker = Mocker()
settings = Settings()
filemock = mocker.mock()
filemock.list_files(directories=settings.tests_dirs, pattern=settings.file_pattern)
mocker.result([])
with mocker:
parser = FileParser(file_object=filemock)
fixture = parser.get_stories(settings=settings)
assert isinstance(fixture, Fixture)
开发者ID:Desperado,项目名称:pyccuracy,代码行数:14,代码来源:test_file_parser.py
示例13: test_parse_scenario_line
def test_parse_scenario_line():
story = Story(as_a="Someone", i_want_to="Do Something", so_that="I'm Happy", identity="some file")
settings_mock = Mock()
settings_mock.scenarios_to_run = []
language_mock = Mock()
language_mock.expects(once()) \
.get(eq("scenario")) \
.will(return_value("Scenario")) \
parser = FileParser(language=language_mock, file_object=None)
scenario = parser.parse_scenario_line(story, "Scenario 1 - Doing something", settings_mock)
assert scenario is not None
assert scenario.index == "1", "Expected 1 actual %s" % scenario.index
assert scenario.title == "Doing something"
language_mock.verify()
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:19,代码来源:test_file_parser.py
示例14: test_parse_scenario_line
def test_parse_scenario_line():
mocker = Mocker()
story = Story(as_a="Someone", i_want_to="Do Something", so_that="I'm Happy", identity="some file")
settings_mock = mocker.mock()
settings_mock.scenarios_to_run
mocker.result([])
language_mock = mocker.mock()
language_mock.get("scenario")
mocker.result("Scenario")
with mocker:
parser = FileParser(language=language_mock, file_object=None)
scenario = parser.parse_scenario_line(story, "Scenario 1 - Doing something", settings_mock)
assert scenario is not None
assert scenario.index == "1", "Expected 1 actual %s" % scenario.index
assert scenario.title == "Doing something"
开发者ID:Desperado,项目名称:pyccuracy,代码行数:21,代码来源:test_file_parser.py
示例15: test_parsing_files_with_invalid_so_that_returns_invalid_files_list
def test_parsing_files_with_invalid_so_that_returns_invalid_files_list():
settings = Settings()
files = ["some path"]
story_text = """As a someone
I want to do something
So I'm happy"""
filemock = Mock()
filemock.expects(once()) \
.list_files(directories=same(settings.tests_dirs), pattern=same(settings.file_pattern)) \
.will(return_value(files))
filemock.expects(once()) \
.read_file(eq(files[0])) \
.will(return_value(story_text))
language_mock = Mock()
language_mock.expects(once()) \
.get(eq("as_a")) \
.will(return_value("As a"))
language_mock.expects(once()) \
.get(eq("i_want_to")) \
.will(return_value("I want to"))
language_mock.expects(once()) \
.get(eq("so_that")) \
.will(return_value("So that"))
language_mock.expects(once()) \
.get(eq("no_header_failure")) \
.will(return_value("No header found"))
parser = FileParser(language=language_mock, file_object=filemock)
fixture = parser.get_stories(settings=settings)
assert len(fixture.no_story_header) == 1
file_path = fixture.no_story_header[0]
assert file_path == "some path"
language_mock.verify()
filemock.verify()
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:38,代码来源:test_file_parser.py
示例16: test_parse_block_lines
def test_parse_block_lines():
parser = FileParser(None, None, None)
line_index = 5
line = "And I see table as:"
scenario_lines = [
'Line 1',
'Line 2',
'Line 3',
'Scenario bla',
'Given',
' And I see table as:',
' | Name | Age | Sex |',
' | Paul | 28 | Male |',
' | John | 30 | Male |'
]
offset, rows, parsed_rows = parser.parse_rows(line_index, line, scenario_lines)
assert offset == 3
assert rows == [
' | Name | Age | Sex |',
' | Paul | 28 | Male |',
' | John | 30 | Male |'
]
assert parsed_rows == [
{
'Name':'Paul',
'Age':'28',
'Sex':'Male'
},
{
'Name':'John',
'Age':'30',
'Sex':'Male'
}
]
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:36,代码来源:test_parser.py
示例17: test_parsing_files_with_proper_header_returns_parsed_scenario
def test_parsing_files_with_proper_header_returns_parsed_scenario():
settings = Settings()
files = ["some path"]
story_text = """As a someone
I want to do something
So that I'm happy"""
filemock = Mock()
filemock.expects(once()) \
.list_files(directories=same(settings.tests_dirs), pattern=same(settings.file_pattern)) \
.will(return_value(files))
filemock.expects(once()) \
.read_file(eq(files[0])) \
.will(return_value(story_text))
language_mock = Mock()
language_mock.expects(once()) \
.get(eq("as_a")) \
.will(return_value("As a"))
language_mock.expects(once()) \
.get(eq("i_want_to")) \
.will(return_value("I want to"))
language_mock.expects(once()) \
.get(eq("so_that")) \
.will(return_value("So that"))
parser = FileParser(language=language_mock, file_object=filemock)
fixture = parser.get_stories(settings=settings)
assert len(fixture.stories) == 1
assert fixture.stories[0].as_a == "someone"
assert fixture.stories[0].i_want_to == "do something"
assert fixture.stories[0].so_that == "I'm happy"
language_mock.verify()
filemock.verify()
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:36,代码来源:test_file_parser.py
示例18: test_parsing_files_with_many_scenarios_returns_parsed_scenarios
def test_parsing_files_with_many_scenarios_returns_parsed_scenarios():
class DoSomethingAction:
def execute(context, *args, **kwargs):
pass
class DoSomethingElseAction:
def execute(context, *args, **kwargs):
pass
class DoYetAnotherThingAction:
def execute(context, *args, **kwargs):
pass
settings = Settings()
files = ["some path"]
story_text = """As a someone
I want to do something
So that I'm happy
Scenario 1 - Test Scenario
Given
I do something
When
I do something else
Then
I do yet another thing
Scenario 2 - Test Scenario
Given
I do something
When
#some custom comment
Then
I do yet another thing"""
filemock = Mock()
filemock.expects(once()) \
.list_files(directories=same(settings.tests_dirs), pattern=same(settings.file_pattern)) \
.will(return_value(files))
filemock.expects(once()) \
.read_file(eq(files[0])) \
.will(return_value(story_text))
language_mock = Mock()
language_mock.expects(at_least_once()) \
.get(eq("as_a")) \
.will(return_value("As a"))
language_mock.expects(at_least_once()) \
.get(eq("i_want_to")) \
.will(return_value("I want to"))
language_mock.expects(at_least_once()) \
.get(eq("so_that")) \
.will(return_value("So that"))
language_mock.expects(at_least_once()) \
.get(eq("given")) \
.will(return_value("Given"))
language_mock.expects(at_least_once()) \
.get(eq("when")) \
.will(return_value("When"))
language_mock.expects(at_least_once()) \
.get(eq("then")) \
.will(return_value("Then"))
language_mock.expects(at_least_once()) \
.get(eq("scenario")) \
.will(return_value("Scenario"))
action_registry_mock = Mock()
action_registry_mock.expects(at_least_once()) \
.suitable_for(eq("I do something"), eq('en-us')) \
.will(return_value((DoSomethingAction, [], {})))
action_registry_mock.expects(at_least_once()) \
.suitable_for(eq("I do something else"), eq('en-us')) \
.will(return_value((DoSomethingElseAction, [], {})))
action_registry_mock.expects(at_least_once()) \
.suitable_for(eq("I do yet another thing"), eq('en-us')) \
.will(return_value((DoYetAnotherThingAction, [], {})))
parser = FileParser(language=language_mock, file_object=filemock, action_registry=action_registry_mock)
fixture = parser.get_stories(settings=settings)
assert_no_invalid_stories(fixture)
assert len(fixture.stories) == 1, "Expected 1, Actual: %d" % len(fixture.stories)
assert len(fixture.stories[0].scenarios) == 2
assert fixture.stories[0].scenarios[1].whens[0].description == "#some custom comment"
language_mock.verify()
filemock.verify()
action_registry_mock.verify()
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:90,代码来源:test_file_parser.py
注:本文中的pyccuracy.parsers.FileParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论