diff options
author | Brett Cannon <bcannon@gmail.com> | 2009-03-09 03:35:50 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2009-03-09 03:35:50 (GMT) |
commit | 2a922ed6adf28fabd10cb852133be5aeeb906aa5 (patch) | |
tree | 233b1352e48970174dade4ca795d853b8cc6e501 /Lib/importlib/test/test_abc.py | |
parent | aa1c8d88992d482f90268f2352fccb6e74d87279 (diff) | |
download | cpython-2a922ed6adf28fabd10cb852133be5aeeb906aa5.zip cpython-2a922ed6adf28fabd10cb852133be5aeeb906aa5.tar.gz cpython-2a922ed6adf28fabd10cb852133be5aeeb906aa5.tar.bz2 |
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.
Diffstat (limited to 'Lib/importlib/test/test_abc.py')
-rw-r--r-- | Lib/importlib/test/test_abc.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/importlib/test/test_abc.py b/Lib/importlib/test/test_abc.py new file mode 100644 index 0000000..a54adb9 --- /dev/null +++ b/Lib/importlib/test/test_abc.py @@ -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() |