mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
gh-71339: Use new assertion methods in test_import and test_importlib (GH-129052)
This commit is contained in:
parent
da310d209a
commit
f7cc7d296c
18 changed files with 51 additions and 54 deletions
|
@ -43,14 +43,12 @@ class InheritanceTests:
|
|||
def test_subclasses(self):
|
||||
# Test that the expected subclasses inherit.
|
||||
for subclass in self.subclasses:
|
||||
self.assertTrue(issubclass(subclass, self.__test),
|
||||
"{0} is not a subclass of {1}".format(subclass, self.__test))
|
||||
self.assertIsSubclass(subclass, self.__test)
|
||||
|
||||
def test_superclasses(self):
|
||||
# Test that the class inherits from the expected superclasses.
|
||||
for superclass in self.superclasses:
|
||||
self.assertTrue(issubclass(self.__test, superclass),
|
||||
"{0} is not a superclass of {1}".format(superclass, self.__test))
|
||||
self.assertIsSubclass(self.__test, superclass)
|
||||
|
||||
|
||||
class MetaPathFinder(InheritanceTests):
|
||||
|
@ -424,14 +422,14 @@ class InspectLoaderSourceToCodeTests:
|
|||
# Since compile() can handle strings, so should source_to_code().
|
||||
source = 'attr = 42'
|
||||
module = self.source_to_module(source)
|
||||
self.assertTrue(hasattr(module, 'attr'))
|
||||
self.assertHasAttr(module, 'attr')
|
||||
self.assertEqual(module.attr, 42)
|
||||
|
||||
def test_source_to_code_bytes(self):
|
||||
# Since compile() can handle bytes, so should source_to_code().
|
||||
source = b'attr = 42'
|
||||
module = self.source_to_module(source)
|
||||
self.assertTrue(hasattr(module, 'attr'))
|
||||
self.assertHasAttr(module, 'attr')
|
||||
self.assertEqual(module.attr, 42)
|
||||
|
||||
def test_source_to_code_path(self):
|
||||
|
@ -765,7 +763,7 @@ class SourceOnlyLoaderTests(SourceLoaderTestHarness):
|
|||
warnings.simplefilter('ignore', DeprecationWarning)
|
||||
module = self.loader.load_module(self.name)
|
||||
self.verify_module(module)
|
||||
self.assertFalse(hasattr(module, '__path__'))
|
||||
self.assertNotHasAttr(module, '__path__')
|
||||
|
||||
def test_get_source_encoding(self):
|
||||
# Source is considered encoded in UTF-8 by default unless otherwise
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue