mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
#9424: Replace deprecated assert* methods in the Python test suite.
This commit is contained in:
parent
b8bc439b20
commit
b3aedd4862
170 changed files with 2388 additions and 2392 deletions
|
|
@ -920,8 +920,8 @@ class TestCase(object):
|
|||
self.fail(self._formatMessage(msg, standardMsg))
|
||||
|
||||
def assertDictEqual(self, d1, d2, msg=None):
|
||||
self.assert_(isinstance(d1, dict), 'First argument is not a dictionary')
|
||||
self.assert_(isinstance(d2, dict), 'Second argument is not a dictionary')
|
||||
self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
|
||||
self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
|
||||
|
||||
if d1 != d2:
|
||||
standardMsg = '%s != %s' % (safe_repr(d1, True), safe_repr(d2, True))
|
||||
|
|
@ -1039,10 +1039,8 @@ class TestCase(object):
|
|||
|
||||
def assertMultiLineEqual(self, first, second, msg=None):
|
||||
"""Assert that two multi-line strings are equal."""
|
||||
self.assert_(isinstance(first, str), (
|
||||
'First argument is not a string'))
|
||||
self.assert_(isinstance(second, str), (
|
||||
'Second argument is not a string'))
|
||||
self.assertIsInstance(first, str, 'First argument is not a string')
|
||||
self.assertIsInstance(second, str, 'Second argument is not a string')
|
||||
|
||||
if first != second:
|
||||
firstlines = first.splitlines(True)
|
||||
|
|
|
|||
|
|
@ -130,11 +130,11 @@ class TestLongMessage(unittest.TestCase):
|
|||
self.assertFalse(unittest.TestCase.longMessage)
|
||||
|
||||
def test_formatMsg(self):
|
||||
self.assertEquals(self.testableFalse._formatMessage(None, "foo"), "foo")
|
||||
self.assertEquals(self.testableFalse._formatMessage("foo", "bar"), "foo")
|
||||
self.assertEqual(self.testableFalse._formatMessage(None, "foo"), "foo")
|
||||
self.assertEqual(self.testableFalse._formatMessage("foo", "bar"), "foo")
|
||||
|
||||
self.assertEquals(self.testableTrue._formatMessage(None, "foo"), "foo")
|
||||
self.assertEquals(self.testableTrue._formatMessage("foo", "bar"), "bar : foo")
|
||||
self.assertEqual(self.testableTrue._formatMessage(None, "foo"), "foo")
|
||||
self.assertEqual(self.testableTrue._formatMessage("foo", "bar"), "bar : foo")
|
||||
|
||||
# This blows up if _formatMessage uses string concatenation
|
||||
self.testableTrue._formatMessage(object(), 'foo')
|
||||
|
|
|
|||
|
|
@ -167,11 +167,11 @@ class Test_TestLoader(unittest.TestCase):
|
|||
loader = unittest.TestLoader()
|
||||
suite = loader.loadTestsFromModule(m)
|
||||
self.assertIsInstance(suite, unittest.TestSuite)
|
||||
self.assertEquals(load_tests_args, [loader, suite, None])
|
||||
self.assertEqual(load_tests_args, [loader, suite, None])
|
||||
|
||||
load_tests_args = []
|
||||
suite = loader.loadTestsFromModule(m, use_load_tests=False)
|
||||
self.assertEquals(load_tests_args, [])
|
||||
self.assertEqual(load_tests_args, [])
|
||||
|
||||
def test_loadTestsFromModule__faulty_load_tests(self):
|
||||
m = types.ModuleType('m')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue