summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test/test_abc.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-07-20 18:48:53 (GMT)
committerBrett Cannon <brett@python.org>2012-07-20 18:48:53 (GMT)
commit45a5e3afe52ed89f298242143c5f7e2bb992ac63 (patch)
tree2255a23f991f1452335d865939f6c30d7b2d7d48 /Lib/importlib/test/test_abc.py
parent4afc1c08d04a9c083b654178ea4f947563510836 (diff)
downloadcpython-45a5e3afe52ed89f298242143c5f7e2bb992ac63.zip
cpython-45a5e3afe52ed89f298242143c5f7e2bb992ac63.tar.gz
cpython-45a5e3afe52ed89f298242143c5f7e2bb992ac63.tar.bz2
Issue #15168: Move importlb.test to test.test_importlib.
This should make the Linux distros happy as it is now easier to leave importlib's tests out of their base Python distribution.
Diffstat (limited to 'Lib/importlib/test/test_abc.py')
-rw-r--r--Lib/importlib/test/test_abc.py96
1 files changed, 0 insertions, 96 deletions
diff --git a/Lib/importlib/test/test_abc.py b/Lib/importlib/test/test_abc.py
deleted file mode 100644
index 008bd21..0000000
--- a/Lib/importlib/test/test_abc.py
+++ /dev/null
@@ -1,96 +0,0 @@
-from importlib import abc
-from importlib import machinery
-import inspect
-import unittest
-
-
-class InheritanceTests:
-
- """Test that the specified class is a subclass/superclass of the expected
- classes."""
-
- subclasses = []
- superclasses = []
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- assert self.subclasses or self.superclasses, self.__class__
- self.__test = getattr(abc, self.__class__.__name__)
-
- 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))
-
- 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))
-
-
-class Finder(InheritanceTests, unittest.TestCase):
-
- subclasses = [machinery.BuiltinImporter, machinery.FrozenImporter,
- machinery.PathFinder]
-
-
-class Loader(InheritanceTests, unittest.TestCase):
-
- subclasses = [abc.PyLoader]
-
-
-class ResourceLoader(InheritanceTests, unittest.TestCase):
-
- superclasses = [abc.Loader]
-
-
-class InspectLoader(InheritanceTests, unittest.TestCase):
-
- superclasses = [abc.Loader]
- subclasses = [abc.PyLoader, machinery.BuiltinImporter,
- machinery.FrozenImporter, machinery.ExtensionFileLoader]
-
-
-class ExecutionLoader(InheritanceTests, unittest.TestCase):
-
- superclasses = [abc.InspectLoader]
- subclasses = [abc.PyLoader]
-
-
-class FileLoader(InheritanceTests, unittest.TestCase):
-
- superclasses = [abc.ResourceLoader, abc.ExecutionLoader]
- subclasses = [machinery.SourceFileLoader, machinery.SourcelessFileLoader]
-
-
-class SourceLoader(InheritanceTests, unittest.TestCase):
-
- superclasses = [abc.ResourceLoader, abc.ExecutionLoader]
- subclasses = [machinery.SourceFileLoader]
-
-
-class PyLoader(InheritanceTests, unittest.TestCase):
-
- superclasses = [abc.Loader, abc.ResourceLoader, abc.ExecutionLoader]
-
-
-class PyPycLoader(InheritanceTests, unittest.TestCase):
-
- superclasses = [abc.PyLoader]
-
-
-def test_main():
- from test.support import run_unittest
- classes = []
- for class_ in globals().values():
- if (inspect.isclass(class_) and
- issubclass(class_, unittest.TestCase) and
- issubclass(class_, InheritanceTests)):
- classes.append(class_)
- run_unittest(*classes)
-
-
-if __name__ == '__main__':
- test_main()