mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Merged revisions 78116 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78116 | michael.foord | 2010-02-08 22:41:16 +0000 (Mon, 08 Feb 2010) | 1 line Make assertMultiLineEqual the default for comparing unicode strings. ........
This commit is contained in:
parent
4900823027
commit
0283495c30
3 changed files with 21 additions and 8 deletions
|
@ -690,13 +690,18 @@ Test cases
|
||||||
*second*.
|
*second*.
|
||||||
|
|
||||||
In addition, if *first* and *second* are the exact same type and one of
|
In addition, if *first* and *second* are the exact same type and one of
|
||||||
list, tuple, dict, set, or frozenset or any type that a subclass
|
list, tuple, dict, set, frozenset or str or any type that a subclass
|
||||||
registers :meth:`addTypeEqualityFunc` the type specific equality function
|
registers with :meth:`addTypeEqualityFunc` the type specific equality
|
||||||
will be called in order to generate a more useful default error message.
|
function will be called in order to generate a more useful default
|
||||||
|
error message.
|
||||||
|
|
||||||
.. versionchanged:: 3.1
|
.. versionchanged:: 3.1
|
||||||
Added the automatic calling of type specific equality function.
|
Added the automatic calling of type specific equality function.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.2
|
||||||
|
:meth:`assertMultiLineEqual` added as the default type equality
|
||||||
|
function for comparing strings.
|
||||||
|
|
||||||
.. deprecated:: 3.1
|
.. deprecated:: 3.1
|
||||||
:meth:`failUnlessEqual`.
|
:meth:`failUnlessEqual`.
|
||||||
|
|
||||||
|
@ -772,7 +777,8 @@ Test cases
|
||||||
|
|
||||||
Test that the multiline string *first* is equal to the string *second*.
|
Test that the multiline string *first* is equal to the string *second*.
|
||||||
When not equal a diff of the two strings highlighting the differences
|
When not equal a diff of the two strings highlighting the differences
|
||||||
will be included in the error message.
|
will be included in the error message. This method is used by default
|
||||||
|
when comparing strings with :meth:`assertEqual`.
|
||||||
|
|
||||||
If specified *msg* will be used as the error message on failure.
|
If specified *msg* will be used as the error message on failure.
|
||||||
|
|
||||||
|
@ -818,7 +824,8 @@ Test cases
|
||||||
.. method:: assertSetEqual(set1, set2, msg=None)
|
.. method:: assertSetEqual(set1, set2, msg=None)
|
||||||
|
|
||||||
Tests that two sets are equal. If not, an error message is constructed
|
Tests that two sets are equal. If not, an error message is constructed
|
||||||
that lists the differences between the sets.
|
that lists the differences between the sets. This method is used by
|
||||||
|
default when comparing sets or frozensets with :meth:`assertEqual`.
|
||||||
|
|
||||||
Fails if either of *set1* or *set2* does not have a :meth:`set.difference`
|
Fails if either of *set1* or *set2* does not have a :meth:`set.difference`
|
||||||
method.
|
method.
|
||||||
|
@ -831,7 +838,9 @@ Test cases
|
||||||
.. method:: assertDictEqual(expected, actual, msg=None)
|
.. method:: assertDictEqual(expected, actual, msg=None)
|
||||||
|
|
||||||
Test that two dictionaries are equal. If not, an error message is
|
Test that two dictionaries are equal. If not, an error message is
|
||||||
constructed that shows the differences in the dictionaries.
|
constructed that shows the differences in the dictionaries. This
|
||||||
|
method will be used by default to compare dictionaries in
|
||||||
|
calls to :meth:`assertEqual`.
|
||||||
|
|
||||||
If specified *msg* will be used as the error message on failure.
|
If specified *msg* will be used as the error message on failure.
|
||||||
|
|
||||||
|
@ -855,6 +864,8 @@ Test cases
|
||||||
Tests that two lists or tuples are equal. If not an error message is
|
Tests that two lists or tuples are equal. If not an error message is
|
||||||
constructed that shows only the differences between the two. An error
|
constructed that shows only the differences between the two. An error
|
||||||
is also raised if either of the parameters are of the wrong type.
|
is also raised if either of the parameters are of the wrong type.
|
||||||
|
These methods are used by default when comparing lists or tuples with
|
||||||
|
:meth:`assertEqual`.
|
||||||
|
|
||||||
If specified *msg* will be used as the error message on failure.
|
If specified *msg* will be used as the error message on failure.
|
||||||
|
|
||||||
|
|
|
@ -2795,8 +2795,9 @@ test case
|
||||||
try:
|
try:
|
||||||
self.assertMultiLineEqual(sample_text, revised_sample_text)
|
self.assertMultiLineEqual(sample_text, revised_sample_text)
|
||||||
except self.failureException as e:
|
except self.failureException as e:
|
||||||
# no fair testing ourself with ourself, use assertEqual..
|
# no fair testing ourself with ourself, and assertEqual is used for strings
|
||||||
self.assertEqual(sample_text_error, str(e))
|
# so can't use assertEqual either. Just use assertTrue.
|
||||||
|
self.assertTrue(sample_text_error == str(e))
|
||||||
|
|
||||||
def testAssertIsNone(self):
|
def testAssertIsNone(self):
|
||||||
self.assertIsNone(None)
|
self.assertIsNone(None)
|
||||||
|
|
|
@ -189,6 +189,7 @@ class TestCase(object):
|
||||||
self.addTypeEqualityFunc(tuple, self.assertTupleEqual)
|
self.addTypeEqualityFunc(tuple, self.assertTupleEqual)
|
||||||
self.addTypeEqualityFunc(set, self.assertSetEqual)
|
self.addTypeEqualityFunc(set, self.assertSetEqual)
|
||||||
self.addTypeEqualityFunc(frozenset, self.assertSetEqual)
|
self.addTypeEqualityFunc(frozenset, self.assertSetEqual)
|
||||||
|
self.addTypeEqualityFunc(str, self.assertMultiLineEqual)
|
||||||
|
|
||||||
def addTypeEqualityFunc(self, typeobj, function):
|
def addTypeEqualityFunc(self, typeobj, function):
|
||||||
"""Add a type specific assertEqual style function to compare a type.
|
"""Add a type specific assertEqual style function to compare a type.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue