]> granicus.if.org Git - python/commitdiff
Issue #16803: Stop having test.test_importlib.abc ABCs inherit from
authorBrett Cannon <brett@python.org>
Fri, 25 Oct 2013 16:33:59 +0000 (12:33 -0400)
committerBrett Cannon <brett@python.org>
Fri, 25 Oct 2013 16:33:59 +0000 (12:33 -0400)
unittest.TestCase in prep of running tests under frozen and source
importlib.

Lib/test/test_importlib/abc.py
Lib/test/test_importlib/builtin/test_finder.py
Lib/test/test_importlib/builtin/test_loader.py
Lib/test/test_importlib/extension/test_finder.py
Lib/test/test_importlib/extension/test_loader.py
Lib/test/test_importlib/frozen/test_finder.py
Lib/test/test_importlib/frozen/test_loader.py
Lib/test/test_importlib/source/test_file_loader.py
Lib/test/test_importlib/source/test_finder.py

index 2c17ac329bc2f9cb0c202963ed4816170acbc604..b9ff3448f7c3c7375cd161822dd6663b05d518e6 100644 (file)
@@ -2,7 +2,7 @@ import abc
 import unittest
 
 
-class FinderTests(unittest.TestCase, metaclass=abc.ABCMeta):
+class FinderTests(metaclass=abc.ABCMeta):
 
     """Basic tests for a finder to pass."""
 
@@ -39,7 +39,7 @@ class FinderTests(unittest.TestCase, metaclass=abc.ABCMeta):
         pass
 
 
-class LoaderTests(unittest.TestCase, metaclass=abc.ABCMeta):
+class LoaderTests(metaclass=abc.ABCMeta):
 
     @abc.abstractmethod
     def test_module(self):
index 146538d891db52d8cdcee1606150bd64f75157fb..4280217cdc6c1bed9c45570f9c59d46bc5a83fc1 100644 (file)
@@ -6,7 +6,7 @@ from . import util as builtin_util
 import sys
 import unittest
 
-class FinderTests(abc.FinderTests):
+class FinderTests(unittest.TestCase, abc.FinderTests):
 
     """Test find_module() for built-in modules."""
 
@@ -46,10 +46,5 @@ class FinderTests(abc.FinderTests):
 
 
 
-def test_main():
-    from test.support import run_unittest
-    run_unittest(FinderTests)
-
-
 if __name__ == '__main__':
-    test_main()
+    unittest.main()
index 8e186e71560e2ba0f5ee8f35491aa9b58c8b5c8f..8eba4e8be425ebfe7a492f18d95c6bad941ce14e 100644 (file)
@@ -9,7 +9,7 @@ import types
 import unittest
 
 
-class LoaderTests(abc.LoaderTests):
+class LoaderTests(unittest.TestCase, abc.LoaderTests):
 
     """Test load_module() for built-in modules."""
 
index a63cfdb9b46db914303fd4de8f763f7bb21efe15..8fa32708609b579cc462de8d83b4ba5a1bae1a5f 100644 (file)
@@ -4,7 +4,7 @@ from . import util
 
 import unittest
 
-class FinderTests(abc.FinderTests):
+class FinderTests(unittest.TestCase, abc.FinderTests):
 
     """Test the finder for extension modules."""
 
index ca5af201c4d6c8ecfe0c14dbf570d106609e3640..12576252a2d713f009d402e7abd7d5dfe5e5d636 100644 (file)
@@ -8,7 +8,7 @@ import sys
 import unittest
 
 
-class LoaderTests(abc.LoaderTests):
+class LoaderTests(unittest.TestCase, abc.LoaderTests):
 
     """Test load_module() for extension modules."""
 
index fa0c2a037e92aec8ef487d41654c7736d6a5c65f..1d37c72821d6cc95f6a77b90bc3924e6e21728e2 100644 (file)
@@ -4,7 +4,7 @@ from .. import abc
 import unittest
 
 
-class FinderTests(abc.FinderTests):
+class FinderTests(unittest.TestCase, abc.FinderTests):
 
     """Test finding frozen modules."""
 
index 3e801388d45fb9b2229cdaffa9855a4e8b92c3c5..eb1f016656db54573489a5eaa3d7dc7d14c18699 100644 (file)
@@ -7,7 +7,7 @@ from test.support import captured_stdout
 import types
 
 
-class LoaderTests(abc.LoaderTests):
+class LoaderTests(unittest.TestCase, abc.LoaderTests):
 
     def test_module(self):
         with util.uncache('__hello__'), captured_stdout() as stdout:
index 66ad96e68e32c53c7680aec68f45f28019532aa1..9e035ea97bee14c6a6e3289104b24298425ce7f6 100644 (file)
@@ -19,7 +19,7 @@ import unittest
 from test.support import make_legacy_pyc, unload
 
 
-class SimpleTest(unittest.TestCase):
+class SimpleTest(unittest.TestCase, abc.LoaderTests):
 
     """Should have no issue importing a source module [basic]. And if there is
     a syntax error, it should raise a SyntaxError [syntax error].
@@ -177,6 +177,11 @@ class SimpleTest(unittest.TestCase):
             # The pyc file was created.
             os.stat(compiled)
 
+    def test_unloadable(self):
+        loader = machinery.SourceFileLoader('good name', {})
+        with self.assertRaises(ImportError):
+            loader.load_module('bad name')
+
 
 class BadBytecodeTest(unittest.TestCase):
 
index 2d70691e5ab8112a143f16fea6334041927ecd3a..9d6cec05103b0b1293171d666644b6884332998f 100644 (file)
@@ -13,7 +13,7 @@ import unittest
 import warnings
 
 
-class FinderTests(abc.FinderTests):
+class FinderTests(unittest.TestCase, abc.FinderTests):
 
     """For a top-level module, it should just be found directly in the
     directory being searched. This is true for a directory with source