mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +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
|
@ -42,7 +42,7 @@ class Using__package__(unittest.TestCase):
|
|||
module = import_util.import_('',
|
||||
globals={'__package__': 'pkg.fake'},
|
||||
fromlist=['attr'], level=2)
|
||||
self.assertEquals(module.__name__, 'pkg')
|
||||
self.assertEqual(module.__name__, 'pkg')
|
||||
|
||||
def test_using___name__(self, package_as_None=False):
|
||||
# [__name__]
|
||||
|
@ -54,7 +54,7 @@ class Using__package__(unittest.TestCase):
|
|||
import_util.import_('pkg.fake')
|
||||
module = import_util.import_('', globals= globals_,
|
||||
fromlist=['attr'], level=2)
|
||||
self.assertEquals(module.__name__, 'pkg')
|
||||
self.assertEqual(module.__name__, 'pkg')
|
||||
|
||||
def test_None_as___package__(self):
|
||||
# [None]
|
||||
|
|
|
@ -54,7 +54,7 @@ class UseCache(unittest.TestCase):
|
|||
with self.create_mock('module') as mock:
|
||||
with util.import_state(meta_path=[mock]):
|
||||
module = import_util.import_('module')
|
||||
self.assertEquals(id(module), id(sys.modules['module']))
|
||||
self.assertEqual(id(module), id(sys.modules['module']))
|
||||
|
||||
# See test_using_cache_after_loader() for reasoning.
|
||||
@import_util.importlib_only
|
||||
|
@ -74,8 +74,8 @@ class UseCache(unittest.TestCase):
|
|||
with util.import_state(meta_path=[importer]):
|
||||
module = import_util.import_('pkg', fromlist=['module'])
|
||||
self.assertTrue(hasattr(module, 'module'))
|
||||
self.assertEquals(id(module.module),
|
||||
id(sys.modules['pkg.module']))
|
||||
self.assertEqual(id(module.module),
|
||||
id(sys.modules['pkg.module']))
|
||||
|
||||
|
||||
def test_main():
|
||||
|
|
|
@ -19,14 +19,14 @@ class ReturnValue(unittest.TestCase):
|
|||
with util.mock_modules('pkg.__init__', 'pkg.module') as importer:
|
||||
with util.import_state(meta_path=[importer]):
|
||||
module = import_util.import_('pkg.module')
|
||||
self.assertEquals(module.__name__, 'pkg')
|
||||
self.assertEqual(module.__name__, 'pkg')
|
||||
|
||||
def test_return_from_from_import(self):
|
||||
# [from return]
|
||||
with util.mock_modules('pkg.__init__', 'pkg.module')as importer:
|
||||
with util.import_state(meta_path=[importer]):
|
||||
module = import_util.import_('pkg.module', fromlist=['attr'])
|
||||
self.assertEquals(module.__name__, 'pkg.module')
|
||||
self.assertEqual(module.__name__, 'pkg.module')
|
||||
|
||||
|
||||
class HandlingFromlist(unittest.TestCase):
|
||||
|
@ -51,14 +51,14 @@ class HandlingFromlist(unittest.TestCase):
|
|||
with util.mock_modules('module') as importer:
|
||||
with util.import_state(meta_path=[importer]):
|
||||
module = import_util.import_('module', fromlist=['attr'])
|
||||
self.assertEquals(module.__name__, 'module')
|
||||
self.assertEqual(module.__name__, 'module')
|
||||
|
||||
def test_unexistent_object(self):
|
||||
# [bad object]
|
||||
with util.mock_modules('module') as importer:
|
||||
with util.import_state(meta_path=[importer]):
|
||||
module = import_util.import_('module', fromlist=['non_existent'])
|
||||
self.assertEquals(module.__name__, 'module')
|
||||
self.assertEqual(module.__name__, 'module')
|
||||
self.assertTrue(not hasattr(module, 'non_existent'))
|
||||
|
||||
def test_module_from_package(self):
|
||||
|
@ -66,23 +66,23 @@ class HandlingFromlist(unittest.TestCase):
|
|||
with util.mock_modules('pkg.__init__', 'pkg.module') as importer:
|
||||
with util.import_state(meta_path=[importer]):
|
||||
module = import_util.import_('pkg', fromlist=['module'])
|
||||
self.assertEquals(module.__name__, 'pkg')
|
||||
self.assertEqual(module.__name__, 'pkg')
|
||||
self.assertTrue(hasattr(module, 'module'))
|
||||
self.assertEquals(module.module.__name__, 'pkg.module')
|
||||
self.assertEqual(module.module.__name__, 'pkg.module')
|
||||
|
||||
def test_no_module_from_package(self):
|
||||
# [no module]
|
||||
with util.mock_modules('pkg.__init__') as importer:
|
||||
with util.import_state(meta_path=[importer]):
|
||||
module = import_util.import_('pkg', fromlist='non_existent')
|
||||
self.assertEquals(module.__name__, 'pkg')
|
||||
self.assertEqual(module.__name__, 'pkg')
|
||||
self.assertTrue(not hasattr(module, 'non_existent'))
|
||||
|
||||
def test_empty_string(self):
|
||||
with util.mock_modules('pkg.__init__', 'pkg.mod') as importer:
|
||||
with util.import_state(meta_path=[importer]):
|
||||
module = import_util.import_('pkg.mod', fromlist=[''])
|
||||
self.assertEquals(module.__name__, 'pkg.mod')
|
||||
self.assertEqual(module.__name__, 'pkg.mod')
|
||||
|
||||
def basic_star_test(self, fromlist=['*']):
|
||||
# [using *]
|
||||
|
@ -90,7 +90,7 @@ class HandlingFromlist(unittest.TestCase):
|
|||
with util.import_state(meta_path=[mock]):
|
||||
mock['pkg'].__all__ = ['module']
|
||||
module = import_util.import_('pkg', fromlist=fromlist)
|
||||
self.assertEquals(module.__name__, 'pkg')
|
||||
self.assertEqual(module.__name__, 'pkg')
|
||||
self.assertTrue(hasattr(module, 'module'))
|
||||
self.assertEqual(module.module.__name__, 'pkg.module')
|
||||
|
||||
|
@ -108,11 +108,11 @@ class HandlingFromlist(unittest.TestCase):
|
|||
with util.import_state(meta_path=[mock]):
|
||||
mock['pkg'].__all__ = ['module1']
|
||||
module = import_util.import_('pkg', fromlist=['module2', '*'])
|
||||
self.assertEquals(module.__name__, 'pkg')
|
||||
self.assertEqual(module.__name__, 'pkg')
|
||||
self.assertTrue(hasattr(module, 'module1'))
|
||||
self.assertTrue(hasattr(module, 'module2'))
|
||||
self.assertEquals(module.module1.__name__, 'pkg.module1')
|
||||
self.assertEquals(module.module2.__name__, 'pkg.module2')
|
||||
self.assertEqual(module.module1.__name__, 'pkg.module1')
|
||||
self.assertEqual(module.module2.__name__, 'pkg.module2')
|
||||
|
||||
|
||||
def test_main():
|
||||
|
|
|
@ -21,7 +21,7 @@ class CallingOrder(unittest.TestCase):
|
|||
first.modules[mod] = 42
|
||||
second.modules[mod] = -13
|
||||
with util.import_state(meta_path=[first, second]):
|
||||
self.assertEquals(import_util.import_(mod), 42)
|
||||
self.assertEqual(import_util.import_(mod), 42)
|
||||
|
||||
def test_continuing(self):
|
||||
# [continuing]
|
||||
|
@ -31,7 +31,7 @@ class CallingOrder(unittest.TestCase):
|
|||
first.find_module = lambda self, fullname, path=None: None
|
||||
second.modules[mod_name] = 42
|
||||
with util.import_state(meta_path=[first, second]):
|
||||
self.assertEquals(import_util.import_(mod_name), 42)
|
||||
self.assertEqual(import_util.import_(mod_name), 42)
|
||||
|
||||
|
||||
class CallSignature(unittest.TestCase):
|
||||
|
@ -61,9 +61,9 @@ class CallSignature(unittest.TestCase):
|
|||
args = log[0][0]
|
||||
kwargs = log[0][1]
|
||||
# Assuming all arguments are positional.
|
||||
self.assertEquals(len(args), 2)
|
||||
self.assertEquals(len(kwargs), 0)
|
||||
self.assertEquals(args[0], mod_name)
|
||||
self.assertEqual(len(args), 2)
|
||||
self.assertEqual(len(kwargs), 0)
|
||||
self.assertEqual(args[0], mod_name)
|
||||
self.assertTrue(args[1] is None)
|
||||
|
||||
def test_with_path(self):
|
||||
|
@ -83,7 +83,7 @@ class CallSignature(unittest.TestCase):
|
|||
kwargs = log[1][1]
|
||||
# Assuming all arguments are positional.
|
||||
self.assertTrue(not kwargs)
|
||||
self.assertEquals(args[0], mod_name)
|
||||
self.assertEqual(args[0], mod_name)
|
||||
self.assertTrue(args[1] is path)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue