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:
Brett Cannon 2009-03-09 03:35:50 +00:00
parent aa1c8d8899
commit 2a922ed6ad
9 changed files with 739 additions and 171 deletions

View 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()