Merge lp:~mbp/bzr/error-reporting into lp:bzr/2.3

Proposed by Martin Pool
Status: Merged
Approved by: Martin Packman
Approved revision: no longer in the source branch.
Merged at revision: 5635
Proposed branch: lp:~mbp/bzr/error-reporting
Merge into: lp:bzr/2.3
Diff against target: 95 lines (+5/-37)
4 files modified
bzrlib/tests/__init__.py (+0/-20)
bzrlib/tests/test_crash.py (+5/-4)
bzrlib/tests/test_selftest.py (+0/-8)
doc/en/release-notes/bzr-2.3.txt (+0/-5)
To merge this branch: bzr merge lp:~mbp/bzr/error-reporting
Reviewer Review Type Date Requested Status
Martin Packman (community) Approve
Review via email: mp+55857@code.launchpad.net

Commit message

use testtools doctest matcher, rather than reimplementing it

Description of the change

This is an updated version fixing the problem mgz noted that it duplicates testtools too much.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Oo, I've never seen doctest.REPORT_UDIFF before, will have to find out what it does.

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

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/__init__.py'
2--- bzrlib/tests/__init__.py 2011-03-29 05:19:48 +0000
3+++ bzrlib/tests/__init__.py 2011-04-01 00:24:12 +0000
4@@ -1450,26 +1450,6 @@
5 else:
6 self.assertEqual(expected_docstring, obj.__doc__)
7
8- def assertDoctestExampleMatches(self, expected, actual, optionflags=None):
9- """Check for a doctest-style string match.
10-
11- :param optionflags: or'd together integers from doctest, typically
12- including ELLIPSIS. If not passed, reasonable defaults are passed.
13- """
14- checker = doctest.OutputChecker()
15- if optionflags is None:
16- # XXX: More here by default?
17- optionflags = doctest.ELLIPSIS | doctest.REPORT_UDIFF
18- if not checker.check_output(expected, actual, optionflags):
19- # The Doctest api insists on an internal object here but doesn't
20- # really need it; just pretend.
21- class FakeExample:
22- pass
23- example = FakeExample()
24- example.want = expected
25- self.fail("doctest-type check failed: "
26- + checker.output_difference(example, actual, optionflags))
27-
28 def failUnlessExists(self, path):
29 """Fail unless path or paths, which may be abs or relative, exist."""
30 if not isinstance(path, basestring):
31
32=== modified file 'bzrlib/tests/test_crash.py'
33--- bzrlib/tests/test_crash.py 2011-03-31 05:45:39 +0000
34+++ bzrlib/tests/test_crash.py 2011-04-01 00:24:12 +0000
35@@ -20,6 +20,7 @@
36 from StringIO import StringIO
37 import sys
38
39+from testtools.matchers import DocTestMatches
40
41 from bzrlib import (
42 config,
43@@ -94,7 +95,9 @@
44 except AssertionError, e:
45 pass
46 crash.report_bug_legacy(sys.exc_info(), err_file)
47- self.assertDoctestExampleMatches("""\
48+ self.assertThat(
49+ err_file.getvalue(),
50+ DocTestMatches("""\
51 bzr: ERROR: exceptions.AssertionError: my error
52
53 Traceback (most recent call last):
54@@ -110,6 +113,4 @@
55 bug in Bazaar. You can help us fix it by filing a bug report at
56 https://bugs.launchpad.net/bzr/+filebug
57 including this traceback and a description of the problem.
58-""",
59- err_file.getvalue(),
60- )
61+""", flags=doctest.ELLIPSIS|doctest.REPORT_UDIFF))
62
63=== modified file 'bzrlib/tests/test_selftest.py'
64--- bzrlib/tests/test_selftest.py 2011-03-29 04:43:16 +0000
65+++ bzrlib/tests/test_selftest.py 2011-04-01 00:24:12 +0000
66@@ -1327,14 +1327,6 @@
67 self.assertEqual('Incorrect length: wanted 2, got 3 for [1, 2, 3]',
68 exception.args[0])
69
70- def test_assertDoctestExampleMatches(self):
71- self.assertDoctestExampleMatches("expected", "expected")
72- self.assertDoctestExampleMatches("hello ... world",
73- "hello round blue world")
74- self.assertRaises(AssertionError,
75- self.assertDoctestExampleMatches,
76- "blue\n", "green\n")
77-
78 def test_base_setUp_not_called_causes_failure(self):
79 class TestCaseWithBrokenSetUp(tests.TestCase):
80 def setUp(self):
81
82=== modified file 'doc/en/release-notes/bzr-2.3.txt'
83--- doc/en/release-notes/bzr-2.3.txt 2011-03-31 10:02:46 +0000
84+++ doc/en/release-notes/bzr-2.3.txt 2011-04-01 00:24:12 +0000
85@@ -87,11 +87,6 @@
86 (<http://psf.upfronthosting.co.za/roundup/tracker/issue8194> should be fixed
87 in python > 2.7.1). (Vincent Ladeuil, #654733)
88
89-* New assertion method `assertDoctestExampleMatches` allows easily reusing
90- doctest string template matches against arbitrary strings.
91- (Martin Pool)
92-
93-
94 bzr 2.3.1
95 #########
96

Subscribers

People subscribed via source and target branches