Merge lp:~jml/subunit/use-traceback-content into lp:~subunit/subunit/trunk

Proposed by Jonathan Lange
Status: Merged
Merged at revision: 161
Proposed branch: lp:~jml/subunit/use-traceback-content
Merge into: lp:~subunit/subunit/trunk
Diff against target: 90 lines (+16/-14)
2 files modified
python/subunit/__init__.py (+4/-4)
python/subunit/tests/test_test_protocol.py (+12/-10)
To merge this branch: bzr merge lp:~jml/subunit/use-traceback-content
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+92337@code.launchpad.net

Description of the change

This addresses bug 929063 by making subunit call TracebackContent rather than _exc_info_to_unicode.

The tests fail for me, but they fail with trunk too. I suspect subunit is out of step with recent testtools formatting changes. This branch doesn't introduce any new failures that I can tell.

Perhaps it's best to land this branch after the testtools side of the fix, https://code.launchpad.net/~jml/testtools/exc-info-929063, lands, so that subunit can be said to rely on a minimum released version of testtools rather than testtools trunk rNNN.

To post a comment you must log in.
158. By Jonathan Lange

Don't make so many assumptions about how testtools formats details.

159. By Jonathan Lange

Code that works for 0.9.11 and against testtools trunk

Revision history for this message
Jonathan Lange (jml) wrote :

The most recent changes (r159) make subunit's Python tests pass with testtools 0.9.11 (the documented minimum version) and with testtools trunk. Actually, it doesn't quite make them work with 0.9.11 because the TracebackContent fix in __init__.py requires 0.9.12 minimum to work.

Let me know if you want me to make that work in 0.9.11 and with trunk. Personally I think we could just make the next release of subunit say minimum testtools 0.9.13 (not yet released) and ditch the compatibility workarounds.

4 shell tests still fail due to test_function_output.sh not expecting time output.

Revision history for this message
Robert Collins (lifeless) wrote :

This looks broadly fine.

I think the next testtools release should be compatible with the current released subunit, and vice-verca; deeper compat when possible is great - avoiding tight locks is nice - but not required.

Will +1 it when it doesn't conflict, because I can't quite tell whats up at the bottom

160. By Jonathan Lange

Merge trunk

161. By Jonathan Lange

Make sure the tests pass with 0.9.11 as well as 0.9.12 & 13

162. By Jonathan Lange

Clean up a flake

Revision history for this message
Jonathan Lange (jml) wrote :

This version should work with 0.9.11, 0.9.12, 0.9.13 and trunk.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Looks good, and great to have compatibility with existing testtools releases.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'python/subunit/__init__.py'
2--- python/subunit/__init__.py 2012-02-10 11:26:44 +0000
3+++ python/subunit/__init__.py 2012-02-16 10:46:21 +0000
4@@ -123,6 +123,7 @@
5 import unittest
6
7 from testtools import content, content_type, ExtendedToOriginalDecorator
8+from testtools.content import TracebackContent
9 from testtools.compat import _b, _u, BytesIO, StringIO
10 try:
11 from testtools.testresult.real import _StringException
12@@ -682,10 +683,9 @@
13 raise ValueError
14 if error is not None:
15 self._stream.write(self._start_simple)
16- # XXX: this needs to be made much stricter, along the lines of
17- # Martin[gz]'s work in testtools. Perhaps subunit can use that?
18- for line in self._exc_info_to_unicode(error, test).splitlines():
19- self._stream.write(("%s\n" % line).encode('utf8'))
20+ tb_content = TracebackContent(error, test)
21+ for bytes in tb_content.iter_bytes():
22+ self._stream.write(bytes)
23 elif details is not None:
24 self._write_details(details)
25 else:
26
27=== modified file 'python/subunit/tests/test_test_protocol.py'
28--- python/subunit/tests/test_test_protocol.py 2012-01-11 05:42:53 +0000
29+++ python/subunit/tests/test_test_protocol.py 2012-02-16 10:46:21 +0000
30@@ -18,9 +18,9 @@
31 import unittest
32 import os
33
34-from testtools import skipIf, TestCase
35-from testtools.compat import _b, _u, BytesIO, StringIO
36-from testtools.content import Content, TracebackContent
37+from testtools import skipIf, TestCase, TestResult
38+from testtools.compat import _b, _u, BytesIO
39+from testtools.content import Content, TracebackContent, text_content
40 from testtools.content_type import ContentType
41 try:
42 from testtools.testresult.doubles import (
43@@ -40,6 +40,10 @@
44 import subunit.iso8601 as iso8601
45
46
47+def details_to_str(details):
48+ return TestResult()._err_details_to_string(None, details=details)
49+
50+
51 class TestTestImports(unittest.TestCase):
52
53 def test_imports(self):
54@@ -87,11 +91,12 @@
55 def test_story(self):
56 client = unittest.TestResult()
57 protocol = subunit.TestProtocolServer(client)
58+ traceback = "foo.c:53:ERROR invalid state\n"
59 pipe = BytesIO(_b("test old mcdonald\n"
60 "success old mcdonald\n"
61 "test bing crosby\n"
62 "failure bing crosby [\n"
63- "foo.c:53:ERROR invalid state\n"
64+ + traceback +
65 "]\n"
66 "test an error\n"
67 "error an error\n"))
68@@ -102,9 +107,8 @@
69 [(an_error, _remote_exception_str + '\n')])
70 self.assertEqual(
71 client.failures,
72- [(bing, _remote_exception_str +
73- ": foo.c:53:ERROR invalid state\n"
74- "\n")])
75+ [(bing, _remote_exception_str + ": "
76+ + details_to_str({'traceback': text_content(traceback)}) + "\n")])
77 self.assertEqual(client.testsRun, 3)
78
79 def test_non_test_characters_forwarded_immediately(self):
80@@ -559,9 +563,7 @@
81 value = details
82 else:
83 if error_message is not None:
84- if not len(error_message.strip()):
85- error_message = _u("Empty attachments:\n traceback\n")
86- value = subunit.RemoteError(_u(error_message))
87+ value = subunit.RemoteError(details_to_str(details))
88 else:
89 value = subunit.RemoteError()
90 self.assertEqual([

Subscribers

People subscribed via source and target branches