]> granicus.if.org Git - python/commitdiff
Issue #19593: Use specific asserts in importlib tests.
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 7 Jul 2014 11:08:19 +0000 (14:08 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 7 Jul 2014 11:08:19 +0000 (14:08 +0300)
Lib/test/test_import.py
Lib/test/test_importlib/builtin/test_loader.py
Lib/test/test_importlib/import_/test_fromlist.py
Lib/test/test_importlib/import_/test_meta_path.py
Lib/test/test_importlib/test_abc.py

index bda1541fdb1aaff57a788f9c9c04ff84a9260fd6..781a159193acaa0faba5abd60e0a1f1cfac08fbb 100644 (file)
@@ -190,12 +190,12 @@ class ImportTests(unittest.TestCase):
         # import x.y.z binds x in the current namespace
         import test as x
         import test.support
-        self.assertTrue(x is test, x.__name__)
+        self.assertIs(x, test, x.__name__)
         self.assertTrue(hasattr(test.support, "__file__"))
 
         # import x.y.z as w binds z as w
         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):
         # A failing reload should leave the module object in sys.modules.
@@ -223,7 +223,7 @@ class ImportTests(unittest.TestCase):
             self.assertRaises(ZeroDivisionError, importlib.reload, mod)
             # But we still expect the module to be in sys.modules.
             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
             # stick.
index a636f778fa5198fc1fc47dc7cf50c01f0e435dd1..1f8357402f670ad38d9eba78b37760deab33748b 100644 (file)
@@ -87,7 +87,7 @@ class InspectLoaderTests:
     def test_is_package(self):
         # Cannot be a package.
         result = self.machinery.BuiltinImporter.is_package(builtin_util.NAME)
-        self.assertTrue(not result)
+        self.assertFalse(result)
 
     def test_not_builtin(self):
         # Modules not built-in should raise ImportError.
index 58f244bddce45c6d02e7ed907482e05df95401ec..a755b75a73ad6e16c6e38b1b1a1ed4fcb63f0489 100644 (file)
@@ -61,7 +61,7 @@ class HandlingFromlist:
             with util.import_state(meta_path=[importer]):
                 module = self.__import__('module', fromlist=['non_existent'])
                 self.assertEqual(module.__name__, 'module')
-                self.assertTrue(not hasattr(module, 'non_existent'))
+                self.assertFalse(hasattr(module, 'non_existent'))
 
     def test_module_from_package(self):
         # [module]
index dc4542062154f670b9dfd6015ff80f31004eb9ce..5eeb1458d34b71b1449cc2b804fda972b7fa16b3 100644 (file)
@@ -96,7 +96,7 @@ class CallSignature:
                 args = log[1][0]
                 kwargs = log[1][1]
                 # Assuming all arguments are positional.
-                self.assertTrue(not kwargs)
+                self.assertFalse(kwargs)
                 self.assertEqual(args[0], mod_name)
                 self.assertIs(args[1], path)
 
index 09b72949ca5f8ec4fbc32d073a0b317c94f17bb6..a1f8e763021a66f8525fdbae4b329196c9a6dd72 100644 (file)
@@ -783,7 +783,7 @@ class SourceOnlyLoaderTests(SourceLoaderTestHarness):
                 warnings.simplefilter('ignore', DeprecationWarning)
                 module = self.loader.load_module(self.name)
             self.verify_module(module)
-            self.assertTrue(not hasattr(module, '__path__'))
+            self.assertFalse(hasattr(module, '__path__'))
 
     def test_get_source_encoding(self):
         # Source is considered encoded in UTF-8 by default unless otherwise