gh-71339: Use new assertion methods in test_import and test_importlib (GH-129052)

This commit is contained in:
Serhiy Storchaka 2025-01-21 11:24:19 +02:00 committed by GitHub
parent da310d209a
commit f7cc7d296c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 51 additions and 54 deletions

View file

@ -430,8 +430,7 @@ class StartupTests:
for name, module in sys.modules.items():
if isinstance(module, types.ModuleType):
with self.subTest(name=name):
self.assertTrue(hasattr(module, '__loader__'),
'{!r} lacks a __loader__ attribute'.format(name))
self.assertHasAttr(module, '__loader__')
if self.machinery.BuiltinImporter.find_spec(name):
self.assertIsNot(module.__loader__, None)
elif self.machinery.FrozenImporter.find_spec(name):
@ -441,7 +440,7 @@ class StartupTests:
for name, module in sys.modules.items():
if isinstance(module, types.ModuleType):
with self.subTest(name=name):
self.assertTrue(hasattr(module, '__spec__'))
self.assertHasAttr(module, '__spec__')
if self.machinery.BuiltinImporter.find_spec(name):
self.assertIsNot(module.__spec__, None)
elif self.machinery.FrozenImporter.find_spec(name):