本文整理汇总了Python中tap.parser.Parser类的典型用法代码示例。如果您正苦于以下问题:Python Parser类的具体用法?Python Parser怎么用?Python Parser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_parses_yaml_no_end
def test_parses_yaml_no_end(self):
sample = inspect.cleandoc(
u"""TAP version 13
1..2
ok 1 A passing test
---
test: sample yaml
not ok 2 A failing test"""
)
parser = Parser()
lines = []
for line in parser.parse_text(sample):
lines.append(line)
try:
import yaml
from more_itertools import peekable # noqa
converted_yaml = yaml.load(u"""test: sample yaml""")
self.assertEqual(4, len(lines))
self.assertEqual(13, lines[0].version)
self.assertEqual(converted_yaml, lines[2].yaml_block)
self.assertEqual("test", lines[3].category)
self.assertIsNone(lines[3].yaml_block)
except ImportError:
self.assertEqual(6, len(lines))
self.assertEqual(13, lines[0].version)
for l in list(range(3, 5)):
self.assertEqual("unknown", lines[l].category)
self.assertEqual("test", lines[5].category)
开发者ID:python-tap,项目名称:tappy,代码行数:31,代码来源:test_parser.py
示例2: test_finds_description
def test_finds_description(self):
parser = Parser()
line = parser.parse_line("ok 42 A passing test.")
self.assertEqual("test", line.category)
self.assertEqual("A passing test.", line.description)
开发者ID:python-tap,项目名称:tappy,代码行数:7,代码来源:test_parser.py
示例3: test_finds_skip
def test_finds_skip(self):
parser = Parser()
line = parser.parse_line('ok A description # SKIP for now')
self.assertEqual('test', line.category)
self.assertTrue(line.skip)
开发者ID:sunny256,项目名称:tappy,代码行数:7,代码来源:test_parser.py
示例4: test_after_hash_is_not_description
def test_after_hash_is_not_description(self):
parser = Parser()
line = parser.parse_line("ok A description # Not part of description.")
self.assertEqual("test", line.category)
self.assertEqual("A description", line.description)
开发者ID:python-tap,项目名称:tappy,代码行数:7,代码来源:test_parser.py
示例5: test_ignores_plan_with_any_non_skip_directive
def test_ignores_plan_with_any_non_skip_directive(self):
"""The parser only recognizes SKIP directives in plans."""
parser = Parser()
line = parser.parse_line('1..42 # TODO will not work.')
self.assertEqual('unknown', line.category)
开发者ID:sunny256,项目名称:tappy,代码行数:7,代码来源:test_parser.py
示例6: test_unrecognizable_line
def test_unrecognizable_line(self):
"""The parser returns an unrecognizable line."""
parser = Parser()
line = parser.parse_line('This is not a valid TAP line. # srsly')
self.assertEqual('unknown', line.category)
开发者ID:sunny256,项目名称:tappy,代码行数:7,代码来源:test_parser.py
示例7: test_finds_todo
def test_finds_todo(self):
parser = Parser()
line = parser.parse_line('ok A description # TODO Not done')
self.assertEqual('test', line.category)
self.assertTrue(line.todo)
开发者ID:sunny256,项目名称:tappy,代码行数:7,代码来源:test_parser.py
示例8: test_finds_plan
def test_finds_plan(self):
"""The parser extracts a plan line."""
parser = Parser()
line = parser.parse_line('1..42')
self.assertEqual('plan', line.category)
self.assertEqual(42, line.expected_tests)
开发者ID:sunny256,项目名称:tappy,代码行数:8,代码来源:test_parser.py
示例9: test_bail_out_line
def test_bail_out_line(self):
"""The parser extracts a bail out line."""
parser = Parser()
line = parser.parse_line('Bail out! This is the reason to bail.')
self.assertEqual('bail', line.category)
self.assertEqual('This is the reason to bail.', line.reason)
开发者ID:sunny256,项目名称:tappy,代码行数:8,代码来源:test_parser.py
示例10: test_finds_plan_with_skip
def test_finds_plan_with_skip(self):
"""The parser extracts a plan line containing a SKIP."""
parser = Parser()
line = parser.parse_line('1..42 # Skipping this test file.')
self.assertEqual('plan', line.category)
self.assertTrue(line.skip)
开发者ID:sunny256,项目名称:tappy,代码行数:8,代码来源:test_parser.py
示例11: test_finds_number
def test_finds_number(self):
"""The parser extracts a test number."""
parser = Parser()
line = parser.parse_line('ok 42 is the magic number.')
self.assertEqual('test', line.category)
self.assertEqual(42, line.number)
开发者ID:sunny256,项目名称:tappy,代码行数:8,代码来源:test_parser.py
示例12: test_finds_version
def test_finds_version(self):
"""The parser extracts a version line."""
parser = Parser()
line = parser.parse_line('TAP version 13')
self.assertEqual('version', line.category)
self.assertEqual(13, line.version)
开发者ID:sunny256,项目名称:tappy,代码行数:8,代码来源:test_parser.py
示例13: test_finds_ok
def test_finds_ok(self):
"""The parser extracts an ok line."""
parser = Parser()
line = parser.parse_line("ok - This is a passing test line.")
self.assertEqual("test", line.category)
self.assertTrue(line.ok)
self.assertTrue(line.number is None)
开发者ID:python-tap,项目名称:tappy,代码行数:9,代码来源:test_parser.py
示例14: test_finds_not_ok
def test_finds_not_ok(self):
"""The parser extracts a not ok line."""
parser = Parser()
line = parser.parse_line('not ok - This is a failing test line.')
self.assertEqual('test', line.category)
self.assertFalse(line.ok)
self.assertTrue(line.number is None)
开发者ID:sunny256,项目名称:tappy,代码行数:9,代码来源:test_parser.py
示例15: test_diagnostic_line
def test_diagnostic_line(self):
"""The parser extracts a diagnostic line."""
text = '# An example diagnostic line'
parser = Parser()
line = parser.parse_line(text)
self.assertEqual('diagnostic', line.category)
self.assertEqual(text, line.text)
开发者ID:sunny256,项目名称:tappy,代码行数:9,代码来源:test_parser.py
示例16: test_finds_not_ok
def test_finds_not_ok(self):
"""The parser extracts a not ok line."""
parser = Parser()
line = parser.parse_line("not ok - This is a failing test line.")
self.assertEqual("test", line.category)
self.assertFalse(line.ok)
self.assertTrue(line.number is None)
self.assertEqual("", line.directive.text)
开发者ID:python-tap,项目名称:tappy,代码行数:10,代码来源:test_parser.py
示例17: test_parse_empty_file
def test_parse_empty_file(self):
temp = tempfile.NamedTemporaryFile(delete=False)
temp.close()
parser = Parser()
lines = []
for line in parser.parse_file(temp.name):
lines.append(line)
self.assertEqual(0, len(lines))
开发者ID:python-tap,项目名称:tappy,代码行数:10,代码来源:test_parser.py
示例18: test_finds_directive
def test_finds_directive(self):
"""The parser extracts a directive"""
parser = Parser()
test_line = "not ok - This line fails # TODO not implemented"
line = parser.parse_line(test_line)
directive = line.directive
self.assertEqual("test", line.category)
self.assertEqual("TODO not implemented", directive.text)
self.assertFalse(directive.skip)
self.assertTrue(directive.todo)
self.assertEqual("not implemented", directive.reason)
开发者ID:python-tap,项目名称:tappy,代码行数:13,代码来源:test_parser.py
示例19: test_parses_stdin
def test_parses_stdin(self):
parser = Parser()
lines = []
for line in parser.parse_stdin():
lines.append(line)
self.assertEqual(3, len(lines))
self.assertEqual("plan", lines[0].category)
self.assertEqual("test", lines[1].category)
self.assertTrue(lines[1].ok)
self.assertEqual("test", lines[2].category)
self.assertFalse(lines[2].ok)
开发者ID:python-tap,项目名称:tappy,代码行数:13,代码来源:test_parser.py
示例20: test_malformed_yaml
def test_malformed_yaml(self):
self.maxDiff = None
sample = inspect.cleandoc(
u"""TAP version 13
1..2
ok 1 A passing test
---
test: sample yaml
\tfail: tabs are not allowed!
...
not ok 2 A failing test"""
)
yaml_err = inspect.cleandoc(
u"""
WARNING: Optional imports not found, TAP 13 output will be
ignored. To parse yaml, see requirements in docs:
https://tappy.readthedocs.io/en/latest/consumers.html#tap-version-13"""
)
parser = Parser()
lines = []
with captured_output() as (parse_out, _):
for line in parser.parse_text(sample):
lines.append(line)
try:
import yaml # noqa
from more_itertools import peekable # noqa
self.assertEqual(4, len(lines))
self.assertEqual(13, lines[0].version)
with captured_output() as (out, _):
self.assertIsNone(lines[2].yaml_block)
self.assertEqual(
"Error parsing yaml block. Check formatting.", out.getvalue().strip()
)
self.assertEqual("test", lines[3].category)
self.assertIsNone(lines[3].yaml_block)
except ImportError:
self.assertEqual(8, len(lines))
self.assertEqual(13, lines[0].version)
for l in list(range(3, 7)):
self.assertEqual("unknown", lines[l].category)
self.assertEqual("test", lines[7].category)
self.assertEqual(yaml_err, parse_out.getvalue().strip())
开发者ID:python-tap,项目名称:tappy,代码行数:45,代码来源:test_parser.py
注:本文中的tap.parser.Parser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论