[3.13] gh-71339: Use new assertion methods in test_import and test_importlib (GH-129052) (#129123)

(cherry picked from commit f7cc7d296c)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Serhiy Storchaka 2025-04-08 13:43:04 +03:00 committed by GitHub
parent d2ec87f740
commit a9bb0092d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 68 additions and 64 deletions

View file

@ -9,6 +9,7 @@ import unittest
from test.support import threading_helper
from test.test_importlib import util as test_util
from test.support.testcase import ExtraAssertions
class CollectInit:
@ -58,7 +59,7 @@ class TestingImporter(abc.MetaPathFinder, abc.Loader):
self.load_count += 1
class LazyLoaderTests(unittest.TestCase):
class LazyLoaderTests(unittest.TestCase, ExtraAssertions):
def test_init(self):
with self.assertRaises(TypeError):
@ -125,12 +126,12 @@ class LazyLoaderTests(unittest.TestCase):
# Deleting an attribute should stay deleted.
module = self.new_module()
del module.attr
self.assertFalse(hasattr(module, 'attr'))
self.assertNotHasAttr(module, 'attr')
def test_delete_preexisting_attr(self):
module = self.new_module()
del module.__name__
self.assertFalse(hasattr(module, '__name__'))
self.assertNotHasAttr(module, '__name__')
def test_module_substitution_error(self):
with test_util.uncache(TestingImporter.module_name):