Rev 4681: Surprisingly, assertEqualDiff was wrong. in file:///home/vila/src/bzr/bugs/assert-equal-diff/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Sep 9 16:27:48 BST 2009
At file:///home/vila/src/bzr/bugs/assert-equal-diff/
------------------------------------------------------------
revno: 4681
revision-id: v.ladeuil+lp at free.fr-20090909152748-vf90nnjybnp84zn2
parent: pqm at pqm.ubuntu.com-20090909134907-nnrr06jw5o011doh
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: assert-equal-diff
timestamp: Wed 2009-09-09 17:27:48 +0200
message:
Surprisingly, assertEqualDiff was wrong.
* bzrlib/tests/test_selftest.py:
(TestExtraAssertions.test_assertEqualDiff): The bug is hard enough
to encounter to deserve some tests.
* bzrlib/tests/__init__.py:
(TestCase.assertEqualDiff): Pedantic and an half.
-------------- next part --------------
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2009-08-28 21:05:31 +0000
+++ b/bzrlib/tests/__init__.py 2009-09-09 15:27:48 +0000
@@ -982,10 +982,10 @@
return
if message is None:
message = "texts not equal:\n"
+ if a + '\n' == b:
+ message = 'first string is missing a final newline.\n'
if a == b + '\n':
message = 'first string is missing a final newline.\n'
- if a + '\n' == b:
- message = 'second string is missing a final newline.\n'
raise AssertionError(message +
self._ndiff_strings(a, b))
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py 2009-09-03 08:10:23 +0000
+++ b/bzrlib/tests/test_selftest.py 2009-09-09 15:27:48 +0000
@@ -1723,6 +1723,21 @@
self.assertEndsWith('foo', 'oo')
self.assertRaises(AssertionError, self.assertEndsWith, 'o', 'oo')
+ def test_assertEqualDiff(self):
+ e = self.assertRaises(AssertionError,
+ self.assertEqualDiff, '', '\n')
+ self.assertEquals(str(e),
+ # Don't blink ! The '+' applies to the second string
+ 'first string is missing a final newline.\n+ \n')
+ e = self.assertRaises(AssertionError,
+ self.assertEqualDiff, '\n', '')
+ self.assertEquals(str(e),
+ # Don't blink ! The '-' applies to the second string
+ 'second string is missing a final newline.\n- \n')
+
+
+class TestDeprecations(tests.TestCase):
+
def test_applyDeprecated_not_deprecated(self):
sample_object = ApplyDeprecatedHelper()
# calling an undeprecated callable raises an assertion
More information about the bazaar-commits
mailing list