convert old fail* assertions to assert*

This commit is contained in:
Benjamin Peterson 2009-06-30 23:06:06 +00:00
parent 98d23f2e06
commit c9c0f201fe
275 changed files with 4540 additions and 4540 deletions

View file

@ -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']))

View file

@ -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')

View file

@ -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)

View file

@ -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:

View file

@ -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

View file

@ -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):