Merge lp:~jelmer/bzr/testtools-0.9.12 into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 6050
Proposed branch: lp:~jelmer/bzr/testtools-0.9.12
Merge into: lp:bzr
Diff against target: 106 lines (+40/-18)
2 files modified
bzrlib/tests/test_selftest.py (+38/-18)
doc/en/release-notes/bzr-2.5.txt (+2/-0)
To merge this branch: bzr merge lp:~jelmer/bzr/testtools-0.9.12
Reviewer Review Type Date Requested Status
Martin Pool Needs Fixing
Andrew Bennetts Approve
Review via email: mp+69274@code.launchpad.net

Commit message

Fix support for testtools 0.9.12.

Description of the change

Fix compatibility with the upcoming testtools 0.9.12, which has slightly different (but nicer) output for test results.

To post a comment you must log in.
Revision history for this message
Andrew Bennetts (spiv) wrote :

Looks reasonable. A touch ugly, but not enough to make it worth spending effort to invent something more elegant. It's clear, which is the main thing.

review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

sent to pqm by email

Revision history for this message
Martin Pool (mbp) wrote :

sent to pqm by email

Revision history for this message
Martin Pool (mbp) wrote :

This failed in pqm:

FAIL: bzrlib.tests.test_selftest.TestTestCaseLogDetails.test_xfail_has_no_log
----------------------------------------------------------------------
_StringException: Text attachment: log
------------

------------
Text attachment: traceback
------------
Traceback (most recent call last):
 File "/usr/lib/python2.6/dist-packages/testtools/runtest.py", line 144, in _run_user
   return fn(*args)
 File "/usr/lib/python2.6/dist-packages/testtools/testcase.py", line 465, in _run_test_method
   testMethod()
 File "/home/pqm/bzr-pqm-workdir/home/+trunk/bzrlib/tests/test_selftest.py", line 1780, in test_xfail_has_no_log
   self.assertContainsRe(result_content, 'Text attachment: log')
AssertionError: pattern "Text attachment: log" not found in ""
------------

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/test_selftest.py'
2--- bzrlib/tests/test_selftest.py 2011-08-02 01:10:27 +0000
3+++ bzrlib/tests/test_selftest.py 2011-08-03 17:07:23 +0000
4@@ -29,6 +29,7 @@
5 from testtools import (
6 ExtendedToOriginalDecorator,
7 MultiTestResult,
8+ __version__ as testtools_version,
9 )
10 from testtools.content import Content
11 from testtools.content_type import ContentType
12@@ -1072,17 +1073,31 @@
13 self.expectFailure("No absolute truth", self.assertTrue, True)
14 runner = tests.TextTestRunner(stream=StringIO())
15 result = self.run_test_runner(runner, Test("test_truth"))
16- self.assertContainsRe(runner.stream.getvalue(),
17- "=+\n"
18- "FAIL: \\S+\.test_truth\n"
19- "-+\n"
20- "(?:.*\n)*"
21- "No absolute truth\n"
22- "(?:.*\n)*"
23- "-+\n"
24- "Ran 1 test in .*\n"
25- "\n"
26- "FAILED \\(failures=1\\)\n\\Z")
27+ if testtools_version <= (0, 9, 11):
28+ self.assertContainsRe(runner.stream.getvalue(),
29+ "=+\n"
30+ "FAIL: \\S+\.test_truth\n"
31+ "-+\n"
32+ "(?:.*\n)*"
33+ "No absolute truth\n"
34+ "(?:.*\n)*"
35+ "-+\n"
36+ "Ran 1 test in .*\n"
37+ "\n"
38+ "FAILED \\(failures=1\\)\n\\Z")
39+ else:
40+ self.assertContainsRe(runner.stream.getvalue(),
41+ "=+\n"
42+ "FAIL: \\S+\.test_truth\n"
43+ "-+\n"
44+ "Empty attachments:\n"
45+ " log\n"
46+ "\n"
47+ "reason: {{{No absolute truth}}}\n"
48+ "-+\n"
49+ "Ran 1 test in .*\n"
50+ "\n"
51+ "FAILED \\(failures=1\\)\n\\Z")
52
53 def test_result_decorator(self):
54 # decorate results
55@@ -1247,11 +1262,14 @@
56 lambda trace=False: "ascii")
57 result = self.run_test_runner(tests.TextTestRunner(stream=out),
58 FailureWithUnicode("test_log_unicode"))
59- self.assertContainsRe(out.getvalue(),
60- "Text attachment: log\n"
61- "-+\n"
62- "\d+\.\d+ \\\\u2606\n"
63- "-+\n")
64+ if testtools_version > (0, 9, 11):
65+ self.assertContainsRe(out.getvalue(), "log: {{{\d+\.\d+ \\\\u2606}}}")
66+ else:
67+ self.assertContainsRe(out.getvalue(),
68+ "Text attachment: log\n"
69+ "-+\n"
70+ "\d+\.\d+ \\\\u2606\n"
71+ "-+\n")
72
73
74 class SampleTestCase(tests.TestCase):
75@@ -1736,14 +1754,16 @@
76 result = self._run_test('test_fail')
77 self.assertEqual(1, len(result.failures))
78 result_content = result.failures[0][1]
79- self.assertContainsRe(result_content, 'Text attachment: log')
80+ if testtools_version < (0, 9, 12):
81+ self.assertContainsRe(result_content, 'Text attachment: log')
82 self.assertContainsRe(result_content, 'this was a failing test')
83
84 def test_error_has_log(self):
85 result = self._run_test('test_error')
86 self.assertEqual(1, len(result.errors))
87 result_content = result.errors[0][1]
88- self.assertContainsRe(result_content, 'Text attachment: log')
89+ if testtools_version < (0, 9, 12):
90+ self.assertContainsRe(result_content, 'Text attachment: log')
91 self.assertContainsRe(result_content, 'this test errored')
92
93 def test_skip_has_no_log(self):
94
95=== modified file 'doc/en/release-notes/bzr-2.5.txt'
96--- doc/en/release-notes/bzr-2.5.txt 2011-08-02 18:14:55 +0000
97+++ doc/en/release-notes/bzr-2.5.txt 2011-08-03 17:07:23 +0000
98@@ -142,6 +142,8 @@
99 due to the order that `build_snapshot` performs its actions.
100 (Andrew Bennetts)
101
102+* Fix compatibility with testtools 0.9.12. (Jelmer Vernooij, #815423)
103+
104 * `TestCaseWithMemoryTransport` is faster now: `_check_safety_net` now
105 just compares the bytes in the dirstate file to its pristine state,
106 rather than opening the WorkingTree and calling ``last_revision()``.