summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/importlib/test')
-rw-r--r--Lib/importlib/test/builtin/test_finder.py6
-rw-r--r--Lib/importlib/test/builtin/test_loader.py12
-rw-r--r--Lib/importlib/test/extension/test_finder.py4
-rw-r--r--Lib/importlib/test/extension/test_loader.py6
-rw-r--r--Lib/importlib/test/extension/test_path_hook.py2
-rw-r--r--Lib/importlib/test/frozen/test_finder.py8
-rw-r--r--Lib/importlib/test/frozen/test_loader.py8
-rw-r--r--Lib/importlib/test/import_/test_caching.py6
-rw-r--r--Lib/importlib/test/import_/test_fromlist.py12
-rw-r--r--Lib/importlib/test/import_/test_meta_path.py6
-rw-r--r--Lib/importlib/test/import_/test_packages.py2
-rw-r--r--Lib/importlib/test/import_/test_path.py30
-rw-r--r--Lib/importlib/test/import_/test_relative_imports.py6
-rw-r--r--Lib/importlib/test/source/test_abc_loader.py22
-rw-r--r--Lib/importlib/test/source/test_file_loader.py14
-rw-r--r--Lib/importlib/test/source/test_finder.py10
-rw-r--r--Lib/importlib/test/source/test_path_hook.py2
-rw-r--r--Lib/importlib/test/test_util.py12
18 files changed, 84 insertions, 84 deletions
diff --git a/Lib/importlib/test/builtin/test_finder.py b/Lib/importlib/test/builtin/test_finder.py
index ef8e8fe..40f690e 100644
--- a/Lib/importlib/test/builtin/test_finder.py
+++ b/Lib/importlib/test/builtin/test_finder.py
@@ -14,7 +14,7 @@ class FinderTests(abc.FinderTests):
# Common case.
with util.uncache(builtin_util.NAME):
found = machinery.BuiltinImporter.find_module(builtin_util.NAME)
- self.assert_(found)
+ self.assertTrue(found)
def test_package(self):
# Built-in modules cannot be a package.
@@ -35,14 +35,14 @@ class FinderTests(abc.FinderTests):
def test_failure(self):
assert 'importlib' not in sys.builtin_module_names
loader = machinery.BuiltinImporter.find_module('importlib')
- self.assert_(loader is None)
+ self.assertTrue(loader is None)
def test_ignore_path(self):
# The value for 'path' should always trigger a failed import.
with util.uncache(builtin_util.NAME):
loader = machinery.BuiltinImporter.find_module(builtin_util.NAME,
['pkg'])
- self.assert_(loader is None)
+ self.assertTrue(loader is None)
diff --git a/Lib/importlib/test/builtin/test_loader.py b/Lib/importlib/test/builtin/test_loader.py
index cfedb5d..dff00ce 100644
--- a/Lib/importlib/test/builtin/test_loader.py
+++ b/Lib/importlib/test/builtin/test_loader.py
@@ -18,10 +18,10 @@ class LoaderTests(abc.LoaderTests):
def verify(self, module):
"""Verify that the module matches against what it should have."""
- self.assert_(isinstance(module, types.ModuleType))
+ self.assertTrue(isinstance(module, types.ModuleType))
for attr, value in self.verification.items():
self.assertEqual(getattr(module, attr), value)
- self.assert_(module.__name__ in sys.modules)
+ self.assertTrue(module.__name__ in sys.modules)
load_module = staticmethod(lambda name:
machinery.BuiltinImporter.load_module(name))
@@ -49,7 +49,7 @@ class LoaderTests(abc.LoaderTests):
with util.uncache(builtin_util.NAME):
module1 = self.load_module(builtin_util.NAME)
module2 = self.load_module(builtin_util.NAME)
- self.assert_(module1 is module2)
+ self.assertTrue(module1 is module2)
def test_unloadable(self):
name = 'dssdsdfff'
@@ -70,17 +70,17 @@ class InspectLoaderTests(unittest.TestCase):
def test_get_code(self):
# There is no code object.
result = machinery.BuiltinImporter.get_code(builtin_util.NAME)
- self.assert_(result is None)
+ self.assertTrue(result is None)
def test_get_source(self):
# There is no source.
result = machinery.BuiltinImporter.get_source(builtin_util.NAME)
- self.assert_(result is None)
+ self.assertTrue(result is None)
def test_is_package(self):
# Cannot be a package.
result = machinery.BuiltinImporter.is_package(builtin_util.NAME)
- self.assert_(not result)
+ self.assertTrue(not result)
def test_not_builtin(self):
# Modules not built-in should raise ImportError.
diff --git a/Lib/importlib/test/extension/test_finder.py b/Lib/importlib/test/extension/test_finder.py
index 39e26a7..546a176 100644
--- a/Lib/importlib/test/extension/test_finder.py
+++ b/Lib/importlib/test/extension/test_finder.py
@@ -13,7 +13,7 @@ class FinderTests(abc.FinderTests):
return importer.find_module(fullname)
def test_module(self):
- self.assert_(self.find_module(util.NAME))
+ self.assertTrue(self.find_module(util.NAME))
def test_package(self):
# Extension modules cannot be an __init__ for a package.
@@ -32,7 +32,7 @@ class FinderTests(abc.FinderTests):
pass
def test_failure(self):
- self.assert_(self.find_module('asdfjkl;') is None)
+ self.assertTrue(self.find_module('asdfjkl;') is None)
# XXX Raise an exception if someone tries to use the 'path' argument?
diff --git a/Lib/importlib/test/extension/test_loader.py b/Lib/importlib/test/extension/test_loader.py
index 157a3b6..71841c6 100644
--- a/Lib/importlib/test/extension/test_loader.py
+++ b/Lib/importlib/test/extension/test_loader.py
@@ -23,8 +23,8 @@ class LoaderTests(abc.LoaderTests):
('__file__', ext_util.FILEPATH),
('__package__', '')]:
self.assertEqual(getattr(module, attr), value)
- self.assert_(ext_util.NAME in sys.modules)
- self.assert_(isinstance(module.__loader__,
+ self.assertTrue(ext_util.NAME in sys.modules)
+ self.assertTrue(isinstance(module.__loader__,
_bootstrap._ExtensionFileLoader))
def test_package(self):
@@ -39,7 +39,7 @@ class LoaderTests(abc.LoaderTests):
with util.uncache(ext_util.NAME):
module1 = self.load_module(ext_util.NAME)
module2 = self.load_module(ext_util.NAME)
- self.assert_(module1 is module2)
+ self.assertTrue(module1 is module2)
def test_state_after_failure(self):
# No easy way to trigger a failure after a successful import.
diff --git a/Lib/importlib/test/extension/test_path_hook.py b/Lib/importlib/test/extension/test_path_hook.py
index 8532956..bf2f411 100644
--- a/Lib/importlib/test/extension/test_path_hook.py
+++ b/Lib/importlib/test/extension/test_path_hook.py
@@ -19,7 +19,7 @@ class PathHookTests(unittest.TestCase):
def test_success(self):
# Path hook should handle a directory where a known extension module
# exists.
- self.assert_(hasattr(self.hook(util.PATH), 'find_module'))
+ self.assertTrue(hasattr(self.hook(util.PATH), 'find_module'))
def test_main():
diff --git a/Lib/importlib/test/frozen/test_finder.py b/Lib/importlib/test/frozen/test_finder.py
index 8caac48..db88379 100644
--- a/Lib/importlib/test/frozen/test_finder.py
+++ b/Lib/importlib/test/frozen/test_finder.py
@@ -15,15 +15,15 @@ class FinderTests(abc.FinderTests):
def test_module(self):
name = '__hello__'
loader = self.find(name)
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
def test_package(self):
loader = self.find('__phello__')
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
def test_module_in_package(self):
loader = self.find('__phello__.spam', ['__phello__'])
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
def test_package_in_package(self):
# No frozen package within another package to test with.
@@ -35,7 +35,7 @@ class FinderTests(abc.FinderTests):
def test_failure(self):
loader = self.find('<not real>')
- self.assert_(loader is None)
+ self.assertTrue(loader is None)
def test_main():
diff --git a/Lib/importlib/test/frozen/test_loader.py b/Lib/importlib/test/frozen/test_loader.py
index 472d6ec..fa64f30 100644
--- a/Lib/importlib/test/frozen/test_loader.py
+++ b/Lib/importlib/test/frozen/test_loader.py
@@ -43,7 +43,7 @@ class LoaderTests(abc.LoaderTests):
with util.uncache('__hello__'):
module1 = machinery.FrozenImporter.load_module('__hello__')
module2 = machinery.FrozenImporter.load_module('__hello__')
- self.assert_(module1 is module2)
+ self.assertTrue(module1 is module2)
def test_state_after_failure(self):
# No way to trigger an error in a frozen module.
@@ -65,12 +65,12 @@ class InspectLoaderTests(unittest.TestCase):
code = machinery.FrozenImporter.get_code(name)
mod = imp.new_module(name)
exec(code, mod.__dict__)
- self.assert_(hasattr(mod, 'initialized'))
+ self.assertTrue(hasattr(mod, 'initialized'))
def test_get_source(self):
# Should always return None.
result = machinery.FrozenImporter.get_source('__hello__')
- self.assert_(result is None)
+ self.assertTrue(result is None)
def test_is_package(self):
# Should be able to tell what is a package.
@@ -78,7 +78,7 @@ class InspectLoaderTests(unittest.TestCase):
('__phello__.spam', False))
for name, is_package in test_for:
result = machinery.FrozenImporter.is_package(name)
- self.assert_(bool(result) == is_package)
+ self.assertTrue(bool(result) == is_package)
def test_failure(self):
# Raise ImportError for modules that are not frozen.
diff --git a/Lib/importlib/test/import_/test_caching.py b/Lib/importlib/test/import_/test_caching.py
index e37c69a..cf65b23 100644
--- a/Lib/importlib/test/import_/test_caching.py
+++ b/Lib/importlib/test/import_/test_caching.py
@@ -53,8 +53,8 @@ class UseCache(unittest.TestCase):
with self.create_mock('pkg.__init__', 'pkg.module') as importer:
with util.import_state(meta_path=[importer]):
module = import_util.import_('pkg.module')
- self.assert_(hasattr(module, 'module'))
- self.assert_(id(module.module), id(sys.modules['pkg.module']))
+ self.assertTrue(hasattr(module, 'module'))
+ self.assertTrue(id(module.module), id(sys.modules['pkg.module']))
# See test_using_cache_after_loader() for reasoning.
@import_util.importlib_only
@@ -63,7 +63,7 @@ class UseCache(unittest.TestCase):
with self.create_mock('pkg.__init__', 'pkg.module') as importer:
with util.import_state(meta_path=[importer]):
module = import_util.import_('pkg', fromlist=['module'])
- self.assert_(hasattr(module, 'module'))
+ self.assertTrue(hasattr(module, 'module'))
self.assertEquals(id(module.module),
id(sys.modules['pkg.module']))
diff --git a/Lib/importlib/test/import_/test_fromlist.py b/Lib/importlib/test/import_/test_fromlist.py
index 266a495..340235b 100644
--- a/Lib/importlib/test/import_/test_fromlist.py
+++ b/Lib/importlib/test/import_/test_fromlist.py
@@ -59,7 +59,7 @@ class HandlingFromlist(unittest.TestCase):
with util.import_state(meta_path=[importer]):
module = import_util.import_('module', fromlist=['non_existent'])
self.assertEquals(module.__name__, 'module')
- self.assert_(not hasattr(module, 'non_existent'))
+ self.assertTrue(not hasattr(module, 'non_existent'))
def test_module_from_package(self):
# [module]
@@ -67,7 +67,7 @@ class HandlingFromlist(unittest.TestCase):
with util.import_state(meta_path=[importer]):
module = import_util.import_('pkg', fromlist=['module'])
self.assertEquals(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'module'))
+ self.assertTrue(hasattr(module, 'module'))
self.assertEquals(module.module.__name__, 'pkg.module')
def test_no_module_from_package(self):
@@ -76,7 +76,7 @@ class HandlingFromlist(unittest.TestCase):
with util.import_state(meta_path=[importer]):
module = import_util.import_('pkg', fromlist='non_existent')
self.assertEquals(module.__name__, 'pkg')
- self.assert_(not hasattr(module, 'non_existent'))
+ self.assertTrue(not hasattr(module, 'non_existent'))
def test_empty_string(self):
with util.mock_modules('pkg.__init__', 'pkg.mod') as importer:
@@ -91,7 +91,7 @@ class HandlingFromlist(unittest.TestCase):
mock['pkg'].__all__ = ['module']
module = import_util.import_('pkg', fromlist=['*'])
self.assertEquals(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'module'))
+ self.assertTrue(hasattr(module, 'module'))
self.assertEqual(module.module.__name__, 'pkg.module')
def test_star_with_others(self):
@@ -102,8 +102,8 @@ class HandlingFromlist(unittest.TestCase):
mock['pkg'].__all__ = ['module1']
module = import_util.import_('pkg', fromlist=['module2', '*'])
self.assertEquals(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'module1'))
- self.assert_(hasattr(module, 'module2'))
+ self.assertTrue(hasattr(module, 'module1'))
+ self.assertTrue(hasattr(module, 'module2'))
self.assertEquals(module.module1.__name__, 'pkg.module1')
self.assertEquals(module.module2.__name__, 'pkg.module2')
diff --git a/Lib/importlib/test/import_/test_meta_path.py b/Lib/importlib/test/import_/test_meta_path.py
index 69859b1..5486694 100644
--- a/Lib/importlib/test/import_/test_meta_path.py
+++ b/Lib/importlib/test/import_/test_meta_path.py
@@ -64,7 +64,7 @@ class CallSignature(unittest.TestCase):
self.assertEquals(len(args), 2)
self.assertEquals(len(kwargs), 0)
self.assertEquals(args[0], mod_name)
- self.assert_(args[1] is None)
+ self.assertTrue(args[1] is None)
def test_with_path(self):
# [path set]
@@ -82,9 +82,9 @@ class CallSignature(unittest.TestCase):
args = log[1][0]
kwargs = log[1][1]
# Assuming all arguments are positional.
- self.assert_(not kwargs)
+ self.assertTrue(not kwargs)
self.assertEquals(args[0], mod_name)
- self.assert_(args[1] is path)
+ self.assertTrue(args[1] is path)
diff --git a/Lib/importlib/test/import_/test_packages.py b/Lib/importlib/test/import_/test_packages.py
index 5912c1f..b41c36f 100644
--- a/Lib/importlib/test/import_/test_packages.py
+++ b/Lib/importlib/test/import_/test_packages.py
@@ -13,7 +13,7 @@ class ParentModuleTests(unittest.TestCase):
with util.mock_modules('pkg.__init__', 'pkg.module') as mock:
with util.import_state(meta_path=[mock]):
module = import_util.import_('pkg.module')
- self.assert_('pkg' in sys.modules)
+ self.assertTrue('pkg' in sys.modules)
def test_bad_parent(self):
with util.mock_modules('pkg.module') as mock:
diff --git a/Lib/importlib/test/import_/test_path.py b/Lib/importlib/test/import_/test_path.py
index ede9b5f..0e055b1 100644
--- a/Lib/importlib/test/import_/test_path.py
+++ b/Lib/importlib/test/import_/test_path.py
@@ -19,7 +19,7 @@ class FinderTests(unittest.TestCase):
# Test None returned upon not finding a suitable finder.
module = '<test module>'
with util.import_state():
- self.assert_(machinery.PathFinder.find_module(module) is None)
+ self.assertTrue(machinery.PathFinder.find_module(module) is None)
def test_sys_path(self):
# Test that sys.path is used when 'path' is None.
@@ -30,7 +30,7 @@ class FinderTests(unittest.TestCase):
with util.import_state(path_importer_cache={path: importer},
path=[path]):
loader = machinery.PathFinder.find_module(module)
- self.assert_(loader is importer)
+ self.assertTrue(loader is importer)
def test_path(self):
# Test that 'path' is used when set.
@@ -40,7 +40,7 @@ class FinderTests(unittest.TestCase):
importer = util.mock_modules(module)
with util.import_state(path_importer_cache={path: importer}):
loader = machinery.PathFinder.find_module(module, [path])
- self.assert_(loader is importer)
+ self.assertTrue(loader is importer)
def test_path_hooks(self):
# Test that sys.path_hooks is used.
@@ -51,16 +51,16 @@ class FinderTests(unittest.TestCase):
hook = import_util.mock_path_hook(path, importer=importer)
with util.import_state(path_hooks=[hook]):
loader = machinery.PathFinder.find_module(module, [path])
- self.assert_(loader is importer)
- self.assert_(path in sys.path_importer_cache)
- self.assert_(sys.path_importer_cache[path] is importer)
+ self.assertTrue(loader is importer)
+ self.assertTrue(path in sys.path_importer_cache)
+ self.assertTrue(sys.path_importer_cache[path] is importer)
def test_path_importer_cache_has_None(self):
# Test that if sys.path_importer_cache has None that None is returned.
clear_cache = {path: None for path in sys.path}
with util.import_state(path_importer_cache=clear_cache):
for name in ('asynchat', 'sys', '<test module>'):
- self.assert_(machinery.PathFinder.find_module(name) is None)
+ self.assertTrue(machinery.PathFinder.find_module(name) is None)
def test_path_importer_cache_has_None_continues(self):
# Test that having None in sys.path_importer_cache causes the search to
@@ -71,7 +71,7 @@ class FinderTests(unittest.TestCase):
with util.import_state(path=['1', '2'],
path_importer_cache={'1': None, '2': importer}):
loader = machinery.PathFinder.find_module(module)
- self.assert_(loader is importer)
+ self.assertTrue(loader is importer)
@@ -88,15 +88,15 @@ class DefaultPathFinderTests(unittest.TestCase):
with util.import_state():
nothing = _bootstrap._DefaultPathFinder.find_module(module,
path=[existing_path])
- self.assert_(nothing is None)
- self.assert_(existing_path in sys.path_importer_cache)
- self.assert_(not isinstance(sys.path_importer_cache[existing_path],
+ self.assertTrue(nothing is None)
+ self.assertTrue(existing_path in sys.path_importer_cache)
+ self.assertTrue(not isinstance(sys.path_importer_cache[existing_path],
imp.NullImporter))
nothing = _bootstrap._DefaultPathFinder.find_module(module,
path=[bad_path])
- self.assert_(nothing is None)
- self.assert_(bad_path in sys.path_importer_cache)
- self.assert_(isinstance(sys.path_importer_cache[bad_path],
+ self.assertTrue(nothing is None)
+ self.assertTrue(bad_path in sys.path_importer_cache)
+ self.assertTrue(isinstance(sys.path_importer_cache[bad_path],
imp.NullImporter))
def test_path_importer_cache_has_None(self):
@@ -113,7 +113,7 @@ class DefaultPathFinderTests(unittest.TestCase):
with util.import_state(path_importer_cache={path: None}):
loader = _bootstrap._DefaultPathFinder.find_module(module,
path=[path])
- self.assert_(loader is importer)
+ self.assertTrue(loader is importer)
finally:
_bootstrap._DEFAULT_PATH_HOOK = original_hook
diff --git a/Lib/importlib/test/import_/test_relative_imports.py b/Lib/importlib/test/import_/test_relative_imports.py
index dca0699..5547d4c 100644
--- a/Lib/importlib/test/import_/test_relative_imports.py
+++ b/Lib/importlib/test/import_/test_relative_imports.py
@@ -79,7 +79,7 @@ class RelativeImports(unittest.TestCase):
import_util.import_('pkg') # For __import__().
module = import_util.import_('', global_, fromlist=['mod2'], level=1)
self.assertEqual(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'mod2'))
+ self.assertTrue(hasattr(module, 'mod2'))
self.assertEqual(module.mod2.attr, 'pkg.mod2')
self.relative_import_test(create, globals_, callback)
@@ -105,7 +105,7 @@ class RelativeImports(unittest.TestCase):
module = import_util.import_('', global_, fromlist=['module'],
level=1)
self.assertEqual(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'module'))
+ self.assertTrue(hasattr(module, 'module'))
self.assertEqual(module.module.attr, 'pkg.module')
self.relative_import_test(create, globals_, callback)
@@ -129,7 +129,7 @@ class RelativeImports(unittest.TestCase):
module = import_util.import_('', global_, fromlist=['subpkg2'],
level=2)
self.assertEqual(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'subpkg2'))
+ self.assertTrue(hasattr(module, 'subpkg2'))
self.assertEqual(module.subpkg2.attr, 'pkg.subpkg2.__init__')
def test_deep_import(self):
diff --git a/Lib/importlib/test/source/test_abc_loader.py b/Lib/importlib/test/source/test_abc_loader.py
index 9acc4ad..1ce83fb 100644
--- a/Lib/importlib/test/source/test_abc_loader.py
+++ b/Lib/importlib/test/source/test_abc_loader.py
@@ -133,10 +133,10 @@ class PyLoaderTests(testing_abc.LoaderTests):
mock = self.mocker({name: path})
with util.uncache(name):
module = mock.load_module(name)
- self.assert_(name in sys.modules)
+ self.assertTrue(name in sys.modules)
self.eq_attrs(module, __name__=name, __file__=path, __package__='',
__loader__=mock)
- self.assert_(not hasattr(module, '__path__'))
+ self.assertTrue(not hasattr(module, '__path__'))
return mock, name
def test_package(self):
@@ -145,7 +145,7 @@ class PyLoaderTests(testing_abc.LoaderTests):
mock = self.mocker({name: path})
with util.uncache(name):
module = mock.load_module(name)
- self.assert_(name in sys.modules)
+ self.assertTrue(name in sys.modules)
self.eq_attrs(module, __name__=name, __file__=path,
__path__=[os.path.dirname(path)], __package__=name,
__loader__=mock)
@@ -171,8 +171,8 @@ class PyLoaderTests(testing_abc.LoaderTests):
with util.uncache(name):
sys.modules[name] = module
loaded_module = mock.load_module(name)
- self.assert_(loaded_module is module)
- self.assert_(sys.modules[name] is module)
+ self.assertTrue(loaded_module is module)
+ self.assertTrue(sys.modules[name] is module)
return mock, name
def test_state_after_failure(self):
@@ -184,8 +184,8 @@ class PyLoaderTests(testing_abc.LoaderTests):
with util.uncache(name):
sys.modules[name] = module
self.assertRaises(ZeroDivisionError, mock.load_module, name)
- self.assert_(sys.modules[name] is module)
- self.assert_(hasattr(module, 'blah'))
+ self.assertTrue(sys.modules[name] is module)
+ self.assertTrue(hasattr(module, 'blah'))
return mock
def test_unloadable(self):
@@ -194,7 +194,7 @@ class PyLoaderTests(testing_abc.LoaderTests):
mock.source = b"1/0"
with util.uncache(name):
self.assertRaises(ZeroDivisionError, mock.load_module, name)
- self.assert_(name not in sys.modules)
+ self.assertTrue(name not in sys.modules)
return mock
@@ -293,7 +293,7 @@ class SkipWritingBytecodeTests(unittest.TestCase):
sys.dont_write_bytecode = dont_write_bytecode
with util.uncache(name):
mock.load_module(name)
- self.assert_((name in mock.module_bytecode) is not
+ self.assertTrue((name in mock.module_bytecode) is not
dont_write_bytecode)
def test_no_bytecode_written(self):
@@ -319,7 +319,7 @@ class RegeneratedBytecodeTests(unittest.TestCase):
'magic': bad_magic}})
with util.uncache(name):
mock.load_module(name)
- self.assert_(name in mock.module_bytecode)
+ self.assertTrue(name in mock.module_bytecode)
magic = mock.module_bytecode[name][:4]
self.assertEqual(magic, imp.get_magic())
@@ -332,7 +332,7 @@ class RegeneratedBytecodeTests(unittest.TestCase):
{name: {'path': 'path/to/mod.bytecode', 'mtime': old_mtime}})
with util.uncache(name):
mock.load_module(name)
- self.assert_(name in mock.module_bytecode)
+ self.assertTrue(name in mock.module_bytecode)
mtime = importlib._r_long(mock.module_bytecode[name][4:8])
self.assertEqual(mtime, PyPycLoaderMock.default_mtime)
diff --git a/Lib/importlib/test/source/test_file_loader.py b/Lib/importlib/test/source/test_file_loader.py
index d01a2a7..0384e7d 100644
--- a/Lib/importlib/test/source/test_file_loader.py
+++ b/Lib/importlib/test/source/test_file_loader.py
@@ -23,7 +23,7 @@ class SimpleTest(unittest.TestCase):
loader = _bootstrap._PyPycFileLoader('_temp', mapping['_temp'],
False)
module = loader.load_module('_temp')
- self.assert_('_temp' in sys.modules)
+ self.assertTrue('_temp' in sys.modules)
check = {'__name__': '_temp', '__file__': mapping['_temp'],
'__package__': ''}
for attr, value in check.items():
@@ -35,7 +35,7 @@ class SimpleTest(unittest.TestCase):
mapping['_pkg.__init__'],
True)
module = loader.load_module('_pkg')
- self.assert_('_pkg' in sys.modules)
+ self.assertTrue('_pkg' in sys.modules)
check = {'__name__': '_pkg', '__file__': mapping['_pkg.__init__'],
'__path__': [os.path.dirname(mapping['_pkg.__init__'])],
'__package__': '_pkg'}
@@ -48,7 +48,7 @@ class SimpleTest(unittest.TestCase):
loader = _bootstrap._PyPycFileLoader('_pkg.mod',
mapping['_pkg.mod'], False)
module = loader.load_module('_pkg.mod')
- self.assert_('_pkg.mod' in sys.modules)
+ self.assertTrue('_pkg.mod' in sys.modules)
check = {'__name__': '_pkg.mod', '__file__': mapping['_pkg.mod'],
'__package__': '_pkg'}
for attr, value in check.items():
@@ -73,7 +73,7 @@ class SimpleTest(unittest.TestCase):
# than the original mtime.
loader.source_mtime = self.fake_mtime(loader.source_mtime)
module = loader.load_module('_temp')
- self.assert_('testing_var' in module.__dict__,
+ self.assertTrue('testing_var' in module.__dict__,
"'testing_var' not in "
"{0}".format(list(module.__dict__.keys())))
self.assertEqual(module, sys.modules['_temp'])
@@ -105,7 +105,7 @@ class SimpleTest(unittest.TestCase):
loader = _bootstrap._PyPycFileLoader('_temp', mapping['_temp'],
False)
self.assertRaises(SyntaxError, loader.load_module, '_temp')
- self.assert_('_temp' not in sys.modules)
+ self.assertTrue('_temp' not in sys.modules)
class BadBytecodeTest(unittest.TestCase):
@@ -124,7 +124,7 @@ class BadBytecodeTest(unittest.TestCase):
def import_(self, file, module_name):
loader = _bootstrap._PyPycFileLoader(module_name, file, False)
module = loader.load_module(module_name)
- self.assert_(module_name in sys.modules)
+ self.assertTrue(module_name in sys.modules)
# [bad magic]
@source_util.writes_bytecode_files
@@ -168,7 +168,7 @@ class BadBytecodeTest(unittest.TestCase):
bytecode_file.write(b'AAAA')
self.assertRaises(ValueError, self.import_, mapping['_temp'],
'_temp')
- self.assert_('_temp' not in sys.modules)
+ self.assertTrue('_temp' not in sys.modules)
def test_main():
diff --git a/Lib/importlib/test/source/test_finder.py b/Lib/importlib/test/source/test_finder.py
index dd56429..c495c5a 100644
--- a/Lib/importlib/test/source/test_finder.py
+++ b/Lib/importlib/test/source/test_finder.py
@@ -53,7 +53,7 @@ class FinderTests(abc.FinderTests):
for name in unlink:
os.unlink(mapping[name])
loader = self.import_(mapping['.root'], test)
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
return loader
def test_module(self):
@@ -79,7 +79,7 @@ class FinderTests(abc.FinderTests):
with source_util.create_modules('pkg.__init__', 'pkg.sub') as mapping:
pkg_dir = os.path.dirname(mapping['pkg.__init__'])
loader = self.import_(pkg_dir, 'pkg.sub')
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
# [sub package]
def test_package_in_package(self):
@@ -87,7 +87,7 @@ class FinderTests(abc.FinderTests):
with context as mapping:
pkg_dir = os.path.dirname(mapping['pkg.__init__'])
loader = self.import_(pkg_dir, 'pkg.sub')
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
# [sub empty]
def test_empty_sub_directory(self):
@@ -105,13 +105,13 @@ class FinderTests(abc.FinderTests):
# XXX This is not a blackbox test!
name = '_temp'
loader = self.run_test(name, {'{0}.__init__'.format(name), name})
- self.assert_('__init__' in loader._base_path)
+ self.assertTrue('__init__' in loader._base_path)
def test_failure(self):
with source_util.create_modules('blah') as mapping:
nothing = self.import_(mapping['.root'], 'sdfsadsadf')
- self.assert_(nothing is None)
+ self.assertTrue(nothing is None)
# [empty dir]
def test_empty_dir(self):
diff --git a/Lib/importlib/test/source/test_path_hook.py b/Lib/importlib/test/source/test_path_hook.py
index 71ca508..3efb3be 100644
--- a/Lib/importlib/test/source/test_path_hook.py
+++ b/Lib/importlib/test/source/test_path_hook.py
@@ -10,7 +10,7 @@ class PathHookTest(unittest.TestCase):
def test_success(self):
# XXX Only work on existing directories?
with source_util.create_modules('dummy') as mapping:
- self.assert_(hasattr(_bootstrap._FileFinder(mapping['.root']),
+ self.assertTrue(hasattr(_bootstrap._FileFinder(mapping['.root']),
'find_module'))
diff --git a/Lib/importlib/test/test_util.py b/Lib/importlib/test/test_util.py
index 706128a..406477d 100644
--- a/Lib/importlib/test/test_util.py
+++ b/Lib/importlib/test/test_util.py
@@ -29,8 +29,8 @@ class ModuleForLoaderTests(unittest.TestCase):
module_name = 'a.b.c'
with test_util.uncache(module_name):
module = self.return_module(module_name)
- self.assert_(module_name in sys.modules)
- self.assert_(isinstance(module, types.ModuleType))
+ self.assertTrue(module_name in sys.modules)
+ self.assertTrue(isinstance(module, types.ModuleType))
self.assertEqual(module.__name__, module_name)
def test_reload(self):
@@ -40,7 +40,7 @@ class ModuleForLoaderTests(unittest.TestCase):
with test_util.uncache(name):
sys.modules[name] = module
returned_module = self.return_module(name)
- self.assert_(sys.modules[name] is returned_module)
+ self.assertTrue(sys.modules[name] is returned_module)
def test_new_module_failure(self):
# Test that a module is removed from sys.modules if added but an
@@ -48,7 +48,7 @@ class ModuleForLoaderTests(unittest.TestCase):
name = 'a.b.c'
with test_util.uncache(name):
self.raise_exception(name)
- self.assert_(name not in sys.modules)
+ self.assertTrue(name not in sys.modules)
def test_reload_failure(self):
# Test that a failure on reload leaves the module in-place.
@@ -57,7 +57,7 @@ class ModuleForLoaderTests(unittest.TestCase):
with test_util.uncache(name):
sys.modules[name] = module
self.raise_exception(name)
- self.assert_(sys.modules[name] is module)
+ self.assertTrue(sys.modules[name] is module)
class SetPackageTests(unittest.TestCase):
@@ -71,7 +71,7 @@ class SetPackageTests(unittest.TestCase):
fxn = lambda: module
wrapped = util.set_package(fxn)
wrapped()
- self.assert_(hasattr(module, '__package__'))
+ self.assertTrue(hasattr(module, '__package__'))
self.assertEqual(expect, module.__package__)
def test_top_level(self):