Commit f2c4ba12 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #19593: Use specific asserts in importlib tests.

parents cde9d1ee 344f8316
...@@ -190,12 +190,12 @@ class ImportTests(unittest.TestCase): ...@@ -190,12 +190,12 @@ class ImportTests(unittest.TestCase):
# import x.y.z binds x in the current namespace # import x.y.z binds x in the current namespace
import test as x import test as x
import test.support import test.support
self.assertTrue(x is test, x.__name__) self.assertIs(x, test, x.__name__)
self.assertTrue(hasattr(test.support, "__file__")) self.assertTrue(hasattr(test.support, "__file__"))
# import x.y.z as w binds z as w # import x.y.z as w binds z as w
import test.support as y import test.support as y
self.assertTrue(y is test.support, y.__name__) self.assertIs(y, test.support, y.__name__)
def test_failing_reload(self): def test_failing_reload(self):
# A failing reload should leave the module object in sys.modules. # A failing reload should leave the module object in sys.modules.
...@@ -223,7 +223,7 @@ class ImportTests(unittest.TestCase): ...@@ -223,7 +223,7 @@ class ImportTests(unittest.TestCase):
self.assertRaises(ZeroDivisionError, importlib.reload, mod) self.assertRaises(ZeroDivisionError, importlib.reload, mod)
# But we still expect the module to be in sys.modules. # But we still expect the module to be in sys.modules.
mod = sys.modules.get(TESTFN) mod = sys.modules.get(TESTFN)
self.assertIsNot(mod, None, "expected module to be in sys.modules") self.assertIsNotNone(mod, "expected module to be in sys.modules")
# We should have replaced a w/ 10, but the old b value should # We should have replaced a w/ 10, but the old b value should
# stick. # stick.
......
...@@ -88,7 +88,7 @@ class InspectLoaderTests: ...@@ -88,7 +88,7 @@ class InspectLoaderTests:
def test_is_package(self): def test_is_package(self):
# Cannot be a package. # Cannot be a package.
result = self.machinery.BuiltinImporter.is_package(util.BUILTINS.good_name) result = self.machinery.BuiltinImporter.is_package(util.BUILTINS.good_name)
self.assertTrue(not result) self.assertFalse(result)
@unittest.skipIf(util.BUILTINS.bad_name is None, 'all modules are built in') @unittest.skipIf(util.BUILTINS.bad_name is None, 'all modules are built in')
def test_not_builtin(self): def test_not_builtin(self):
......
...@@ -62,7 +62,7 @@ class HandlingFromlist: ...@@ -62,7 +62,7 @@ class HandlingFromlist:
with util.import_state(meta_path=[importer]): with util.import_state(meta_path=[importer]):
module = self.__import__('module', fromlist=['non_existent']) module = self.__import__('module', fromlist=['non_existent'])
self.assertEqual(module.__name__, 'module') self.assertEqual(module.__name__, 'module')
self.assertTrue(not hasattr(module, 'non_existent')) self.assertFalse(hasattr(module, 'non_existent'))
def test_module_from_package(self): def test_module_from_package(self):
# [module] # [module]
......
...@@ -97,7 +97,7 @@ class CallSignature: ...@@ -97,7 +97,7 @@ class CallSignature:
args = log[1][0] args = log[1][0]
kwargs = log[1][1] kwargs = log[1][1]
# Assuming all arguments are positional. # Assuming all arguments are positional.
self.assertTrue(not kwargs) self.assertFalse(kwargs)
self.assertEqual(args[0], mod_name) self.assertEqual(args[0], mod_name)
self.assertIs(args[1], path) self.assertIs(args[1], path)
......
...@@ -784,7 +784,7 @@ class SourceOnlyLoaderTests(SourceLoaderTestHarness): ...@@ -784,7 +784,7 @@ class SourceOnlyLoaderTests(SourceLoaderTestHarness):
warnings.simplefilter('ignore', DeprecationWarning) warnings.simplefilter('ignore', DeprecationWarning)
module = self.loader.load_module(self.name) module = self.loader.load_module(self.name)
self.verify_module(module) self.verify_module(module)
self.assertTrue(not hasattr(module, '__path__')) self.assertFalse(hasattr(module, '__path__'))
def test_get_source_encoding(self): def test_get_source_encoding(self):
# Source is considered encoded in UTF-8 by default unless otherwise # Source is considered encoded in UTF-8 by default unless otherwise
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment