Kaydet (Commit) b3d6afff authored tarafından Brett Cannon's avatar Brett Cannon

Issue #16803: Stop having test.test_importlib.abc ABCs inherit from

unittest.TestCase in prep of running tests under frozen and source
importlib.
üst c60dd5b0
...@@ -2,7 +2,7 @@ import abc ...@@ -2,7 +2,7 @@ import abc
import unittest import unittest
class FinderTests(unittest.TestCase, metaclass=abc.ABCMeta): class FinderTests(metaclass=abc.ABCMeta):
"""Basic tests for a finder to pass.""" """Basic tests for a finder to pass."""
...@@ -39,7 +39,7 @@ class FinderTests(unittest.TestCase, metaclass=abc.ABCMeta): ...@@ -39,7 +39,7 @@ class FinderTests(unittest.TestCase, metaclass=abc.ABCMeta):
pass pass
class LoaderTests(unittest.TestCase, metaclass=abc.ABCMeta): class LoaderTests(metaclass=abc.ABCMeta):
@abc.abstractmethod @abc.abstractmethod
def test_module(self): def test_module(self):
......
...@@ -6,7 +6,7 @@ from . import util as builtin_util ...@@ -6,7 +6,7 @@ from . import util as builtin_util
import sys import sys
import unittest import unittest
class FinderTests(abc.FinderTests): class FinderTests(unittest.TestCase, abc.FinderTests):
"""Test find_module() for built-in modules.""" """Test find_module() for built-in modules."""
...@@ -46,10 +46,5 @@ class FinderTests(abc.FinderTests): ...@@ -46,10 +46,5 @@ class FinderTests(abc.FinderTests):
def test_main():
from test.support import run_unittest
run_unittest(FinderTests)
if __name__ == '__main__': if __name__ == '__main__':
test_main() unittest.main()
...@@ -9,7 +9,7 @@ import types ...@@ -9,7 +9,7 @@ import types
import unittest import unittest
class LoaderTests(abc.LoaderTests): class LoaderTests(unittest.TestCase, abc.LoaderTests):
"""Test load_module() for built-in modules.""" """Test load_module() for built-in modules."""
......
...@@ -4,7 +4,7 @@ from . import util ...@@ -4,7 +4,7 @@ from . import util
import unittest import unittest
class FinderTests(abc.FinderTests): class FinderTests(unittest.TestCase, abc.FinderTests):
"""Test the finder for extension modules.""" """Test the finder for extension modules."""
......
...@@ -8,7 +8,7 @@ import sys ...@@ -8,7 +8,7 @@ import sys
import unittest import unittest
class LoaderTests(abc.LoaderTests): class LoaderTests(unittest.TestCase, abc.LoaderTests):
"""Test load_module() for extension modules.""" """Test load_module() for extension modules."""
......
...@@ -4,7 +4,7 @@ from .. import abc ...@@ -4,7 +4,7 @@ from .. import abc
import unittest import unittest
class FinderTests(abc.FinderTests): class FinderTests(unittest.TestCase, abc.FinderTests):
"""Test finding frozen modules.""" """Test finding frozen modules."""
......
...@@ -7,7 +7,7 @@ from test.support import captured_stdout ...@@ -7,7 +7,7 @@ from test.support import captured_stdout
import types import types
class LoaderTests(abc.LoaderTests): class LoaderTests(unittest.TestCase, abc.LoaderTests):
def test_module(self): def test_module(self):
with util.uncache('__hello__'), captured_stdout() as stdout: with util.uncache('__hello__'), captured_stdout() as stdout:
......
...@@ -19,7 +19,7 @@ import unittest ...@@ -19,7 +19,7 @@ import unittest
from test.support import make_legacy_pyc, unload 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 """Should have no issue importing a source module [basic]. And if there is
a syntax error, it should raise a SyntaxError [syntax error]. a syntax error, it should raise a SyntaxError [syntax error].
...@@ -177,6 +177,11 @@ class SimpleTest(unittest.TestCase): ...@@ -177,6 +177,11 @@ class SimpleTest(unittest.TestCase):
# The pyc file was created. # The pyc file was created.
os.stat(compiled) 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): class BadBytecodeTest(unittest.TestCase):
......
...@@ -13,7 +13,7 @@ import unittest ...@@ -13,7 +13,7 @@ import unittest
import warnings 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 """For a top-level module, it should just be found directly in the
directory being searched. This is true for a directory with source directory being searched. This is true for a directory with source
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment