summaryrefslogtreecommitdiff
path: root/python/subunit/tests
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2013-03-03 22:28:51 +1300
committerRobert Collins <robertc@robertcollins.net>2013-03-03 22:28:51 +1300
commitb1d5d5881f378273ce0dc8d8301d4ba25bcd4988 (patch)
tree5731c7f2a9f000a5c6aa6784311dd901146dd1a6 /python/subunit/tests
parent1565f398b5520f45be1852c3d8a8ffdcf8dccfe2 (diff)
downloadsubunit-git-b1d5d5881f378273ce0dc8d8301d4ba25bcd4988.tar.gz
Port existing filters to v2.
Diffstat (limited to 'python/subunit/tests')
-rw-r--r--python/subunit/tests/test_subunit_tags.py61
-rw-r--r--python/subunit/tests/test_tap2subunit.py374
2 files changed, 192 insertions, 243 deletions
diff --git a/python/subunit/tests/test_subunit_tags.py b/python/subunit/tests/test_subunit_tags.py
index c98506a..e8d8c3a 100644
--- a/python/subunit/tests/test_subunit_tags.py
+++ b/python/subunit/tests/test_subunit_tags.py
@@ -16,10 +16,9 @@
"""Tests for subunit.tag_stream."""
+from io import BytesIO
import unittest
-from testtools.compat import StringIO
-
import subunit
import subunit.test_results
@@ -27,40 +26,42 @@ import subunit.test_results
class TestSubUnitTags(unittest.TestCase):
def setUp(self):
- self.original = StringIO()
- self.filtered = StringIO()
+ self.original = BytesIO()
+ self.filtered = BytesIO()
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")
+ reference = BytesIO()
+ stream = subunit.StreamResultToBytes(reference)
+ stream.status(
+ test_id='test', test_status='inprogress', test_tags=set(['quux', 'foo']))
+ stream.status(
+ test_id='test', test_status='success', test_tags=set(['bar', 'quux', 'foo']))
+ stream = subunit.StreamResultToBytes(self.original)
+ stream.status(
+ test_id='test', test_status='inprogress', test_tags=set(['foo']))
+ stream.status(
+ test_id='test', test_status='success', test_tags=set(['foo', 'bar']))
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())
+ self.assertEqual(
+ 0, subunit.tag_stream(self.original, self.filtered, ["quux"]))
+ self.assertEqual(reference.getvalue(), self.filtered.getvalue())
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")
+ reference = BytesIO()
+ stream = subunit.StreamResultToBytes(reference)
+ stream.status(
+ test_id='test', test_status='inprogress', test_tags=set(['foo']))
+ stream.status(
+ test_id='test', test_status='success', test_tags=set(['foo']))
+ stream = subunit.StreamResultToBytes(self.original)
+ stream.status(
+ test_id='test', test_status='inprogress', test_tags=set(['foo']))
+ stream.status(
+ test_id='test', test_status='success', test_tags=set(['foo', 'bar']))
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())
+ self.assertEqual(
+ 0, subunit.tag_stream(self.original, self.filtered, ["-bar"]))
+ self.assertEqual(reference.getvalue(), self.filtered.getvalue())
def test_suite():
diff --git a/python/subunit/tests/test_tap2subunit.py b/python/subunit/tests/test_tap2subunit.py
index 11bc191..f689946 100644
--- a/python/subunit/tests/test_tap2subunit.py
+++ b/python/subunit/tests/test_tap2subunit.py
@@ -16,14 +16,19 @@
"""Tests for TAP2SubUnit."""
+from io import BytesIO, StringIO
import unittest
-from testtools.compat import StringIO
+from testtools import TestCase
+from testtools.compat import _u
+from testtools.testresult.doubles import StreamResult
import subunit
+UTF8_TEXT = 'text/plain; charset=UTF8'
-class TestTAP2SubUnit(unittest.TestCase):
+
+class TestTAP2SubUnit(TestCase):
"""Tests for TAP2SubUnit.
These tests test TAP string data in, and subunit string data out.
@@ -34,24 +39,21 @@ class TestTAP2SubUnit(unittest.TestCase):
"""
def setUp(self):
+ super(TestTAP2SubUnit, self).setUp()
self.tap = StringIO()
- self.subunit = StringIO()
+ self.subunit = BytesIO()
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.write(_u("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())
+ self.check_events([('status', 'file skip', 'skip', None, True,
+ 'tap comment', b'Skipped: entire file skipped', True, None, None,
+ None)])
def test_ok_test_pass(self):
# A file
@@ -59,164 +61,128 @@ class TestTAP2SubUnit(unittest.TestCase):
# 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.write(_u("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())
+ self.check_events([('status', 'test 1', 'success', None, False, None,
+ None, True, None, None, None)])
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.write(_u("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())
+ self.check_events([('status', 'test 1', 'success', None, False, None,
+ None, True, None, None, None)])
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.write(_u("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())
+ self.check_events([('status', 'test 1 - There is a description',
+ 'success', None, False, None, None, True, None, None, None)])
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.write(_u("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())
+ self.check_events([('status', 'test 1 There is a description',
+ 'success', None, False, None, None, True, None, None, None)])
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.write(_u("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",
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([('status', 'test 1', 'skip', None, False, None,
+ None, True, None, None, None)])
def test_ok_skip_number_comment_lowercase(self):
- self.tap.write("ok 1 # skip no samba environment available, skipping compilation\n")
+ self.tap.write(_u("ok 1 # skip no samba environment available, skipping compilation\n"))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- "test test 1",
- "skip test 1 [",
- "no samba environment available, skipping compilation",
- "]"
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([('status', 'test 1', 'skip', None, False, 'tap comment',
+ b'no samba environment available, skipping compilation', True,
+ 'text/plain; charset=UTF8', None, None)])
def test_ok_number_description_SKIP_skip_comment(self):
# A file
# ok 1 foo # SKIP Not done yet
# results in a skip test with name 'test 1 foo' and a log of
# Not done yet
- self.tap.write("ok 1 foo # SKIP Not done yet\n")
+ self.tap.write(_u("ok 1 foo # SKIP Not done yet\n"))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- "test test 1 foo",
- "skip test 1 foo [",
- "Not done yet",
- "]",
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([('status', 'test 1 foo', 'skip', None, False,
+ 'tap comment', b'Not done yet', True, 'text/plain; charset=UTF8',
+ None, None)])
def test_ok_SKIP_skip_comment(self):
# A file
# ok # SKIP Not done yet
# results in a skip test with name 'test 1' and a log of Not done yet
- self.tap.write("ok # SKIP Not done yet\n")
+ self.tap.write(_u("ok # SKIP Not done yet\n"))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- "test test 1",
- "skip test 1 [",
- "Not done yet",
- "]",
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([('status', 'test 1', 'skip', None, False,
+ 'tap comment', b'Not done yet', True, 'text/plain; charset=UTF8',
+ None, None)])
def test_ok_TODO_xfail(self):
# A file
# ok # TODO
# results in a xfail test with name 'test 1'
- self.tap.write("ok # TODO\n")
+ self.tap.write(_u("ok # TODO\n"))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- "test test 1",
- "xfail test 1",
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([('status', 'test 1', 'xfail', None, False, None,
+ None, True, None, None, None)])
def test_ok_TODO_xfail_comment(self):
# A file
# ok # TODO Not done yet
# results in a xfail test with name 'test 1' and a log of Not done yet
- self.tap.write("ok # TODO Not done yet\n")
+ self.tap.write(_u("ok # TODO Not done yet\n"))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- "test test 1",
- "xfail test 1 [",
- "Not done yet",
- "]",
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([('status', 'test 1', 'xfail', None, False,
+ 'tap comment', b'Not done yet', True, 'text/plain; charset=UTF8',
+ None, None)])
def test_bail_out_errors(self):
# A file with line in it
# Bail out! COMMENT
# is treated as an error
- self.tap.write("ok 1 foo\n")
- self.tap.write("Bail out! Lifejacket engaged\n")
+ self.tap.write(_u("ok 1 foo\n"))
+ self.tap.write(_u("Bail out! Lifejacket engaged\n"))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- "test test 1 foo",
- "success test 1 foo",
- "test Bail out! Lifejacket engaged",
- "error Bail out! Lifejacket engaged",
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([
+ ('status', 'test 1 foo', 'success', None, False, None, None, True,
+ None, None, None),
+ ('status', 'Bail out! Lifejacket engaged', 'fail', None, False,
+ None, None, True, None, None, None)])
def test_missing_test_at_end_with_plan_adds_error(self):
# A file
@@ -224,23 +190,20 @@ class TestTAP2SubUnit(unittest.TestCase):
# ok first test
# not ok third test
# results in three tests, with the third being created
- self.tap.write('1..3\n')
- self.tap.write('ok first test\n')
- self.tap.write('not ok second test\n')
+ self.tap.write(_u('1..3\n'))
+ self.tap.write(_u('ok first test\n'))
+ self.tap.write(_u('not ok second test\n'))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- 'test test 1 first test',
- 'success test 1 first test',
- 'test test 2 second test',
- 'failure test 2 second test',
- 'test test 3',
- 'error test 3 [',
- 'test missing from TAP output',
- ']',
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([
+ ('status', 'test 1 first test', 'success', None, False, None,
+ None, True, None, None, None),
+ ('status', 'test 2 second test', 'fail', None, False, None, None,
+ True, None, None, None),
+ ('status', 'test 3', 'fail', None, False, 'tap meta',
+ b'test missing from TAP output', True, 'text/plain; charset=UTF8',
+ None, None)])
def test_missing_test_with_plan_adds_error(self):
# A file
@@ -248,45 +211,39 @@ class TestTAP2SubUnit(unittest.TestCase):
# ok first test
# not ok 3 third test
# results in three tests, with the second being created
- self.tap.write('1..3\n')
- self.tap.write('ok first test\n')
- self.tap.write('not ok 3 third test\n')
+ self.tap.write(_u('1..3\n'))
+ self.tap.write(_u('ok first test\n'))
+ self.tap.write(_u('not ok 3 third test\n'))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- 'test test 1 first test',
- 'success test 1 first test',
- 'test test 2',
- 'error test 2 [',
- 'test missing from TAP output',
- ']',
- 'test test 3 third test',
- 'failure test 3 third test',
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([
+ ('status', 'test 1 first test', 'success', None, False, None, None,
+ True, None, None, None),
+ ('status', 'test 2', 'fail', None, False, 'tap meta',
+ b'test missing from TAP output', True, 'text/plain; charset=UTF8',
+ None, None),
+ ('status', 'test 3 third test', 'fail', None, False, None, None,
+ True, None, None, None)])
def test_missing_test_no_plan_adds_error(self):
# A file
# ok first test
# not ok 3 third test
# results in three tests, with the second being created
- self.tap.write('ok first test\n')
- self.tap.write('not ok 3 third test\n')
+ self.tap.write(_u('ok first test\n'))
+ self.tap.write(_u('not ok 3 third test\n'))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- 'test test 1 first test',
- 'success test 1 first test',
- 'test test 2',
- 'error test 2 [',
- 'test missing from TAP output',
- ']',
- 'test test 3 third test',
- 'failure test 3 third test',
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([
+ ('status', 'test 1 first test', 'success', None, False, None, None,
+ True, None, None, None),
+ ('status', 'test 2', 'fail', None, False, 'tap meta',
+ b'test missing from TAP output', True, 'text/plain; charset=UTF8',
+ None, None),
+ ('status', 'test 3 third test', 'fail', None, False, None, None,
+ True, None, None, None)])
def test_four_tests_in_a_row_trailing_plan(self):
# A file
@@ -296,25 +253,23 @@ class TestTAP2SubUnit(unittest.TestCase):
# not ok 4 - fourth
# 1..4
# results in four tests numbered and named
- self.tap.write('ok 1 - first test in a script with trailing plan\n')
- self.tap.write('not ok 2 - second\n')
- self.tap.write('ok 3 - third\n')
- self.tap.write('not ok 4 - fourth\n')
- self.tap.write('1..4\n')
+ self.tap.write(_u('ok 1 - first test in a script with trailing plan\n'))
+ self.tap.write(_u('not ok 2 - second\n'))
+ self.tap.write(_u('ok 3 - third\n'))
+ self.tap.write(_u('not ok 4 - fourth\n'))
+ self.tap.write(_u('1..4\n'))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- 'test test 1 - first test in a script with trailing plan',
- 'success test 1 - first test in a script with trailing plan',
- 'test test 2 - second',
- 'failure test 2 - second',
- 'test test 3 - third',
- 'success test 3 - third',
- 'test test 4 - fourth',
- 'failure test 4 - fourth'
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([
+ ('status', 'test 1 - first test in a script with trailing plan',
+ 'success', None, False, None, None, True, None, None, None),
+ ('status', 'test 2 - second', 'fail', None, False, None, None,
+ True, None, None, None),
+ ('status', 'test 3 - third', 'success', None, False, None, None,
+ True, None, None, None),
+ ('status', 'test 4 - fourth', 'fail', None, False, None, None,
+ True, None, None, None)])
def test_four_tests_in_a_row_with_plan(self):
# A file
@@ -324,25 +279,23 @@ class TestTAP2SubUnit(unittest.TestCase):
# ok 3 - third
# not ok 4 - fourth
# results in four tests numbered and named
- self.tap.write('1..4\n')
- self.tap.write('ok 1 - first test in a script with a plan\n')
- self.tap.write('not ok 2 - second\n')
- self.tap.write('ok 3 - third\n')
- self.tap.write('not ok 4 - fourth\n')
+ self.tap.write(_u('1..4\n'))
+ self.tap.write(_u('ok 1 - first test in a script with a plan\n'))
+ self.tap.write(_u('not ok 2 - second\n'))
+ self.tap.write(_u('ok 3 - third\n'))
+ self.tap.write(_u('not ok 4 - fourth\n'))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- 'test test 1 - first test in a script with a plan',
- 'success test 1 - first test in a script with a plan',
- 'test test 2 - second',
- 'failure test 2 - second',
- 'test test 3 - third',
- 'success test 3 - third',
- 'test test 4 - fourth',
- 'failure test 4 - fourth'
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([
+ ('status', 'test 1 - first test in a script with a plan',
+ 'success', None, False, None, None, True, None, None, None),
+ ('status', 'test 2 - second', 'fail', None, False, None, None,
+ True, None, None, None),
+ ('status', 'test 3 - third', 'success', None, False, None, None,
+ True, None, None, None),
+ ('status', 'test 4 - fourth', 'fail', None, False, None, None,
+ True, None, None, None)])
def test_four_tests_in_a_row_no_plan(self):
# A file
@@ -351,46 +304,43 @@ class TestTAP2SubUnit(unittest.TestCase):
# ok 3 - third
# not ok 4 - fourth
# results in four tests numbered and named
- self.tap.write('ok 1 - first test in a script with no plan at all\n')
- self.tap.write('not ok 2 - second\n')
- self.tap.write('ok 3 - third\n')
- self.tap.write('not ok 4 - fourth\n')
+ self.tap.write(_u('ok 1 - first test in a script with no plan at all\n'))
+ self.tap.write(_u('not ok 2 - second\n'))
+ self.tap.write(_u('ok 3 - third\n'))
+ self.tap.write(_u('not ok 4 - fourth\n'))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- 'test test 1 - first test in a script with no plan at all',
- 'success test 1 - first test in a script with no plan at all',
- 'test test 2 - second',
- 'failure test 2 - second',
- 'test test 3 - third',
- 'success test 3 - third',
- 'test test 4 - fourth',
- 'failure test 4 - fourth'
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([
+ ('status', 'test 1 - first test in a script with no plan at all',
+ 'success', None, False, None, None, True, None, None, None),
+ ('status', 'test 2 - second', 'fail', None, False, None, None,
+ True, None, None, None),
+ ('status', 'test 3 - third', 'success', None, False, None, None,
+ True, None, None, None),
+ ('status', 'test 4 - fourth', 'fail', None, False, None, None,
+ True, None, None, None)])
def test_todo_and_skip(self):
# A file
# not ok 1 - a fail but # TODO but is TODO
# not ok 2 - another fail # SKIP instead
# results in two tests, numbered and commented.
- self.tap.write("not ok 1 - a fail but # TODO but is TODO\n")
- self.tap.write("not ok 2 - another fail # SKIP instead\n")
+ self.tap.write(_u("not ok 1 - a fail but # TODO but is TODO\n"))
+ self.tap.write(_u("not ok 2 - another fail # SKIP instead\n"))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- 'test test 1 - a fail but',
- 'xfail test 1 - a fail but [',
- 'but is TODO',
- ']',
- 'test test 2 - another fail',
- 'skip test 2 - another fail [',
- 'instead',
- ']',
- ],
- self.subunit.getvalue().splitlines())
+ self.subunit.seek(0)
+ events = StreamResult()
+ subunit.ByteStreamToStreamResult(self.subunit).run(events)
+ self.check_events([
+ ('status', 'test 1 - a fail but', 'xfail', None, False,
+ 'tap comment', b'but is TODO', True, 'text/plain; charset=UTF8',
+ None, None),
+ ('status', 'test 2 - another fail', 'skip', None, False,
+ 'tap comment', b'instead', True, 'text/plain; charset=UTF8',
+ None, None)])
def test_leading_comments_add_to_next_test_log(self):
# A file
@@ -399,21 +349,17 @@ class TestTAP2SubUnit(unittest.TestCase):
# ok
# results in a single test with the comment included
# in the first test and not the second.
- self.tap.write("# comment\n")
- self.tap.write("ok\n")
- self.tap.write("ok\n")
+ self.tap.write(_u("# comment\n"))
+ self.tap.write(_u("ok\n"))
+ self.tap.write(_u("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 [',
- '# comment',
- ']',
- 'test test 2',
- 'success test 2',
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([
+ ('status', 'test 1', 'success', None, False, 'tap comment',
+ b'# comment', True, 'text/plain; charset=UTF8', None, None),
+ ('status', 'test 2', 'success', None, False, None, None, True,
+ None, None, None)])
def test_trailing_comments_are_included_in_last_test_log(self):
# A file
@@ -422,21 +368,23 @@ class TestTAP2SubUnit(unittest.TestCase):
# # comment
# results in a two tests, with the second having the comment
# attached to its log.
- self.tap.write("ok\n")
- self.tap.write("ok\n")
- self.tap.write("# comment\n")
+ self.tap.write(_u("ok\n"))
+ self.tap.write(_u("ok\n"))
+ self.tap.write(_u("# comment\n"))
self.tap.seek(0)
result = subunit.TAP2SubUnit(self.tap, self.subunit)
self.assertEqual(0, result)
- self.assertEqual([
- 'test test 1',
- 'success test 1',
- 'test test 2',
- 'success test 2 [',
- '# comment',
- ']',
- ],
- self.subunit.getvalue().splitlines())
+ self.check_events([
+ ('status', 'test 1', 'success', None, False, None, None, True,
+ None, None, None),
+ ('status', 'test 2', 'success', None, False, 'tap comment',
+ b'# comment', True, 'text/plain; charset=UTF8', None, None)])
+
+ def check_events(self, events):
+ self.subunit.seek(0)
+ eventstream = StreamResult()
+ subunit.ByteStreamToStreamResult(self.subunit).run(eventstream)
+ self.assertEqual(events, eventstream._events)
def test_suite():