mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Introduce importlib.abc. The module contains various ABCs related to imports
(mostly stuff specified by PEP 302). There are two ABCs, PyLoader and PyPycLoader, which help with implementing source and source/bytecode loaders by implementing load_module in terms of other methods. This removes a lot of gritty details loaders typically have to worry about.
This commit is contained in:
parent
aa1c8d8899
commit
2a922ed6ad
9 changed files with 739 additions and 171 deletions
31
Lib/importlib/test/test_abc.py
Normal file
31
Lib/importlib/test/test_abc.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from importlib import abc
|
||||
from importlib import machinery
|
||||
import unittest
|
||||
|
||||
|
||||
class SubclassTests(unittest.TestCase):
|
||||
|
||||
"""Test that the various classes in importlib are subclasses of the
|
||||
expected ABCS."""
|
||||
|
||||
def verify(self, ABC, *classes):
|
||||
"""Verify the classes are subclasses of the ABC."""
|
||||
for cls in classes:
|
||||
self.assert_(issubclass(cls, ABC))
|
||||
|
||||
def test_Finder(self):
|
||||
self.verify(abc.Finder, machinery.BuiltinImporter,
|
||||
machinery.FrozenImporter, machinery.PathFinder)
|
||||
|
||||
def test_Loader(self):
|
||||
self.verify(abc.Loader, machinery.BuiltinImporter,
|
||||
machinery.FrozenImporter)
|
||||
|
||||
|
||||
def test_main():
|
||||
from test.support import run_unittest
|
||||
run_unittest(SubclassTests)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_main()
|
Loading…
Add table
Add a link
Reference in a new issue