本文整理汇总了Python中testtools.compat.StringIO.seek方法的典型用法代码示例。如果您正苦于以下问题:Python StringIO.seek方法的具体用法?Python StringIO.seek怎么用?Python StringIO.seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testtools.compat.StringIO
的用法示例。
在下文中一共展示了StringIO.seek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestSubUnitTags
# 需要导入模块: from testtools.compat import StringIO [as 别名]
# 或者: from testtools.compat.StringIO import seek [as 别名]
class TestSubUnitTags(unittest.TestCase):
def setUp(self):
self.original = StringIO()
self.filtered = StringIO()
def test_add_tag(self):
self.original.write("tags: foo\n")
self.original.write("test: test\n")
self.original.write("tags: bar -quux\n")
self.original.write("success: test\n")
self.original.seek(0)
result = subunit.tag_stream(self.original, self.filtered, ["quux"])
self.assertEqual(
["tags: quux", "tags: foo", "test: test", "tags: bar", "success: test"],
self.filtered.getvalue().splitlines(),
)
def test_remove_tag(self):
self.original.write("tags: foo\n")
self.original.write("test: test\n")
self.original.write("tags: bar -quux\n")
self.original.write("success: test\n")
self.original.seek(0)
result = subunit.tag_stream(self.original, self.filtered, ["-bar"])
self.assertEqual(
["tags: -bar", "tags: foo", "test: test", "tags: -quux", "success: test"],
self.filtered.getvalue().splitlines(),
)
示例2: TestTAP2SubUnit
# 需要导入模块: from testtools.compat import StringIO [as 别名]
# 或者: from testtools.compat.StringIO import seek [as 别名]
class TestTAP2SubUnit(unittest.TestCase):
"""Tests for TAP2SubUnit.
These tests test TAP string data in, and subunit string data out.
This is ok because the subunit protocol is intended to be stable,
but it might be easier/pithier to write tests against TAP string in,
parsed subunit objects out (by hooking the subunit stream to a subunit
protocol server.
"""
def setUp(self):
self.tap = StringIO()
self.subunit = StringIO()
def test_skip_entire_file(self):
# A file
# 1..- # Skipped: comment
# results in a single skipped test.
self.tap.write("1..0 # Skipped: entire file skipped\n")
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
self.assertEqual([
"test file skip",
"skip file skip [",
"Skipped: entire file skipped",
"]",
],
self.subunit.getvalue().splitlines())
def test_ok_test_pass(self):
# A file
# ok
# results in a passed test with name 'test 1' (a synthetic name as tap
# does not require named fixtures - it is the first test in the tap
# stream).
self.tap.write("ok\n")
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
self.assertEqual([
"test test 1",
"success test 1",
],
self.subunit.getvalue().splitlines())
def test_ok_test_number_pass(self):
# A file
# ok 1
# results in a passed test with name 'test 1'
self.tap.write("ok 1\n")
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
self.assertEqual([
"test test 1",
"success test 1",
],
self.subunit.getvalue().splitlines())
def test_ok_test_number_description_pass(self):
# A file
# ok 1 - There is a description
# results in a passed test with name 'test 1 - There is a description'
self.tap.write("ok 1 - There is a description\n")
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
self.assertEqual([
"test test 1 - There is a description",
"success test 1 - There is a description",
],
self.subunit.getvalue().splitlines())
def test_ok_test_description_pass(self):
# A file
# ok There is a description
# results in a passed test with name 'test 1 There is a description'
self.tap.write("ok There is a description\n")
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
self.assertEqual([
"test test 1 There is a description",
"success test 1 There is a description",
],
self.subunit.getvalue().splitlines())
def test_ok_SKIP_skip(self):
# A file
# ok # SKIP
# results in a skkip test with name 'test 1'
self.tap.write("ok # SKIP\n")
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
self.assertEqual([
"test test 1",
"skip test 1",
],
#.........这里部分代码省略.........