[Python-checkins] cpython (3.4): Issue #19593: Use specific asserts in importlib tests.

serhiy.storchaka python-checkins at python.org
Mon Jul 7 13:09:41 CEST 2014


http://hg.python.org/cpython/rev/f426bd85f808
changeset:   91573:f426bd85f808
branch:      3.4
parent:      91571:a8db78d7b657
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Mon Jul 07 14:08:19 2014 +0300
summary:
  Issue #19593: Use specific asserts in importlib tests.

files:
  Lib/test/test_import.py                           |  6 +++---
  Lib/test/test_importlib/builtin/test_loader.py    |  2 +-
  Lib/test/test_importlib/import_/test_fromlist.py  |  2 +-
  Lib/test/test_importlib/import_/test_meta_path.py |  2 +-
  Lib/test/test_importlib/test_abc.py               |  2 +-
  5 files changed, 7 insertions(+), 7 deletions(-)


diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -190,12 +190,12 @@
         # 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 @@
             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.
diff --git a/Lib/test/test_importlib/builtin/test_loader.py b/Lib/test/test_importlib/builtin/test_loader.py
--- a/Lib/test/test_importlib/builtin/test_loader.py
+++ b/Lib/test/test_importlib/builtin/test_loader.py
@@ -87,7 +87,7 @@
     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.
diff --git a/Lib/test/test_importlib/import_/test_fromlist.py b/Lib/test/test_importlib/import_/test_fromlist.py
--- a/Lib/test/test_importlib/import_/test_fromlist.py
+++ b/Lib/test/test_importlib/import_/test_fromlist.py
@@ -61,7 +61,7 @@
             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]
diff --git a/Lib/test/test_importlib/import_/test_meta_path.py b/Lib/test/test_importlib/import_/test_meta_path.py
--- a/Lib/test/test_importlib/import_/test_meta_path.py
+++ b/Lib/test/test_importlib/import_/test_meta_path.py
@@ -96,7 +96,7 @@
                 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)
 
diff --git a/Lib/test/test_importlib/test_abc.py b/Lib/test/test_importlib/test_abc.py
--- a/Lib/test/test_importlib/test_abc.py
+++ b/Lib/test/test_importlib/test_abc.py
@@ -783,7 +783,7 @@
                 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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list