Skip to content

Commit f2c4ba1

Browse files
Issue python#19593: Use specific asserts in importlib tests.
2 parents cde9d1e + 344f831 commit f2c4ba1

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

Lib/test/test_import.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ def test_import_name_binding(self):
190190
# import x.y.z binds x in the current namespace
191191
import test as x
192192
import test.support
193-
self.assertTrue(x is test, x.__name__)
193+
self.assertIs(x, test, x.__name__)
194194
self.assertTrue(hasattr(test.support, "__file__"))
195195

196196
# import x.y.z as w binds z as w
197197
import test.support as y
198-
self.assertTrue(y is test.support, y.__name__)
198+
self.assertIs(y, test.support, y.__name__)
199199

200200
def test_failing_reload(self):
201201
# A failing reload should leave the module object in sys.modules.
@@ -223,7 +223,7 @@ def test_failing_reload(self):
223223
self.assertRaises(ZeroDivisionError, importlib.reload, mod)
224224
# But we still expect the module to be in sys.modules.
225225
mod = sys.modules.get(TESTFN)
226-
self.assertIsNot(mod, None, "expected module to be in sys.modules")
226+
self.assertIsNotNone(mod, "expected module to be in sys.modules")
227227

228228
# We should have replaced a w/ 10, but the old b value should
229229
# stick.

Lib/test/test_importlib/builtin/test_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_get_source(self):
8888
def test_is_package(self):
8989
# Cannot be a package.
9090
result = self.machinery.BuiltinImporter.is_package(util.BUILTINS.good_name)
91-
self.assertTrue(not result)
91+
self.assertFalse(result)
9292

9393
@unittest.skipIf(util.BUILTINS.bad_name is None, 'all modules are built in')
9494
def test_not_builtin(self):

Lib/test/test_importlib/import_/test_fromlist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_nonexistent_object(self):
6262
with util.import_state(meta_path=[importer]):
6363
module = self.__import__('module', fromlist=['non_existent'])
6464
self.assertEqual(module.__name__, 'module')
65-
self.assertTrue(not hasattr(module, 'non_existent'))
65+
self.assertFalse(hasattr(module, 'non_existent'))
6666

6767
def test_module_from_package(self):
6868
# [module]

Lib/test/test_importlib/import_/test_meta_path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_with_path(self):
9797
args = log[1][0]
9898
kwargs = log[1][1]
9999
# Assuming all arguments are positional.
100-
self.assertTrue(not kwargs)
100+
self.assertFalse(kwargs)
101101
self.assertEqual(args[0], mod_name)
102102
self.assertIs(args[1], path)
103103

Lib/test/test_importlib/test_abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ def test_package_settings(self):
784784
warnings.simplefilter('ignore', DeprecationWarning)
785785
module = self.loader.load_module(self.name)
786786
self.verify_module(module)
787-
self.assertTrue(not hasattr(module, '__path__'))
787+
self.assertFalse(hasattr(module, '__path__'))
788788

789789
def test_get_source_encoding(self):
790790
# Source is considered encoded in UTF-8 by default unless otherwise

0 commit comments

Comments
 (0)