本文整理匯總了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",
],
#.........這裏部分代碼省略.........