Rev 5635: (mbp) use testtools doctest matcher, in file:///home/pqm/archives/thelove/bzr/2.3/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Apr 1 01:37:46 UTC 2011
At file:///home/pqm/archives/thelove/bzr/2.3/
------------------------------------------------------------
revno: 5635 [merge]
revision-id: pqm at pqm.ubuntu.com-20110401013743-g5nrelt3wx5714o0
parent: pqm at pqm.ubuntu.com-20110331100246-xi0z401lm15xrnr5
parent: mbp at canonical.com-20110401002119-64jup19ewfrxeox3
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.3
timestamp: Fri 2011-04-01 01:37:43 +0000
message:
(mbp) use testtools doctest matcher,
rather than reimplementing it (Martin Pool)
modified:
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/test_crash.py test_crash.py-20090820042958-jglgza3wrn03ha9e-2
bzrlib/tests/test_selftest.py test_selftest.py-20051202044319-c110a115d8c0456a
doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2011-03-29 05:19:48 +0000
+++ b/bzrlib/tests/__init__.py 2011-04-01 00:21:19 +0000
@@ -1450,26 +1450,6 @@
else:
self.assertEqual(expected_docstring, obj.__doc__)
- def assertDoctestExampleMatches(self, expected, actual, optionflags=None):
- """Check for a doctest-style string match.
-
- :param optionflags: or'd together integers from doctest, typically
- including ELLIPSIS. If not passed, reasonable defaults are passed.
- """
- checker = doctest.OutputChecker()
- if optionflags is None:
- # XXX: More here by default?
- optionflags = doctest.ELLIPSIS | doctest.REPORT_UDIFF
- if not checker.check_output(expected, actual, optionflags):
- # The Doctest api insists on an internal object here but doesn't
- # really need it; just pretend.
- class FakeExample:
- pass
- example = FakeExample()
- example.want = expected
- self.fail("doctest-type check failed: "
- + checker.output_difference(example, actual, optionflags))
-
def failUnlessExists(self, path):
"""Fail unless path or paths, which may be abs or relative, exist."""
if not isinstance(path, basestring):
=== modified file 'bzrlib/tests/test_crash.py'
--- a/bzrlib/tests/test_crash.py 2011-03-31 05:45:39 +0000
+++ b/bzrlib/tests/test_crash.py 2011-04-01 00:20:02 +0000
@@ -20,6 +20,7 @@
from StringIO import StringIO
import sys
+from testtools.matchers import DocTestMatches
from bzrlib import (
config,
@@ -94,7 +95,9 @@
except AssertionError, e:
pass
crash.report_bug_legacy(sys.exc_info(), err_file)
- self.assertDoctestExampleMatches("""\
+ self.assertThat(
+ err_file.getvalue(),
+ DocTestMatches("""\
bzr: ERROR: exceptions.AssertionError: my error
Traceback (most recent call last):
@@ -110,6 +113,4 @@
bug in Bazaar. You can help us fix it by filing a bug report at
https://bugs.launchpad.net/bzr/+filebug
including this traceback and a description of the problem.
-""",
- err_file.getvalue(),
- )
+""", flags=doctest.ELLIPSIS|doctest.REPORT_UDIFF))
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py 2011-03-29 04:43:16 +0000
+++ b/bzrlib/tests/test_selftest.py 2011-04-01 00:21:19 +0000
@@ -1327,14 +1327,6 @@
self.assertEqual('Incorrect length: wanted 2, got 3 for [1, 2, 3]',
exception.args[0])
- def test_assertDoctestExampleMatches(self):
- self.assertDoctestExampleMatches("expected", "expected")
- self.assertDoctestExampleMatches("hello ... world",
- "hello round blue world")
- self.assertRaises(AssertionError,
- self.assertDoctestExampleMatches,
- "blue\n", "green\n")
-
def test_base_setUp_not_called_causes_failure(self):
class TestCaseWithBrokenSetUp(tests.TestCase):
def setUp(self):
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt 2011-03-31 10:02:46 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt 2011-04-01 01:37:43 +0000
@@ -87,11 +87,6 @@
(<http://psf.upfronthosting.co.za/roundup/tracker/issue8194> should be fixed
in python > 2.7.1). (Vincent Ladeuil, #654733)
-* New assertion method `assertDoctestExampleMatches` allows easily reusing
- doctest string template matches against arbitrary strings.
- (Martin Pool)
-
-
bzr 2.3.1
#########
More information about the bazaar-commits
mailing list