Skip to content

Commit b3d6aff

Browse files
committed
Issue #16803: Stop having test.test_importlib.abc ABCs inherit from
unittest.TestCase in prep of running tests under frozen and source importlib.
1 parent c60dd5b commit b3d6aff

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

Lib/test/test_importlib/abc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import unittest
33

44

5-
class FinderTests(unittest.TestCase, metaclass=abc.ABCMeta):
5+
class FinderTests(metaclass=abc.ABCMeta):
66

77
"""Basic tests for a finder to pass."""
88

@@ -39,7 +39,7 @@ def test_failure(self):
3939
pass
4040

4141

42-
class LoaderTests(unittest.TestCase, metaclass=abc.ABCMeta):
42+
class LoaderTests(metaclass=abc.ABCMeta):
4343

4444
@abc.abstractmethod
4545
def test_module(self):

Lib/test/test_importlib/builtin/test_finder.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
import unittest
88

9-
class FinderTests(abc.FinderTests):
9+
class FinderTests(unittest.TestCase, abc.FinderTests):
1010

1111
"""Test find_module() for built-in modules."""
1212

@@ -46,10 +46,5 @@ def test_ignore_path(self):
4646

4747

4848

49-
def test_main():
50-
from test.support import run_unittest
51-
run_unittest(FinderTests)
52-
53-
5449
if __name__ == '__main__':
55-
test_main()
50+
unittest.main()

Lib/test/test_importlib/builtin/test_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import unittest
1010

1111

12-
class LoaderTests(abc.LoaderTests):
12+
class LoaderTests(unittest.TestCase, abc.LoaderTests):
1313

1414
"""Test load_module() for built-in modules."""
1515

Lib/test/test_importlib/extension/test_finder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import unittest
66

7-
class FinderTests(abc.FinderTests):
7+
class FinderTests(unittest.TestCase, abc.FinderTests):
88

99
"""Test the finder for extension modules."""
1010

Lib/test/test_importlib/extension/test_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import unittest
99

1010

11-
class LoaderTests(abc.LoaderTests):
11+
class LoaderTests(unittest.TestCase, abc.LoaderTests):
1212

1313
"""Test load_module() for extension modules."""
1414

Lib/test/test_importlib/frozen/test_finder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import unittest
55

66

7-
class FinderTests(abc.FinderTests):
7+
class FinderTests(unittest.TestCase, abc.FinderTests):
88

99
"""Test finding frozen modules."""
1010

Lib/test/test_importlib/frozen/test_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import types
88

99

10-
class LoaderTests(abc.LoaderTests):
10+
class LoaderTests(unittest.TestCase, abc.LoaderTests):
1111

1212
def test_module(self):
1313
with util.uncache('__hello__'), captured_stdout() as stdout:

Lib/test/test_importlib/source/test_file_loader.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from test.support import make_legacy_pyc, unload
2020

2121

22-
class SimpleTest(unittest.TestCase):
22+
class SimpleTest(unittest.TestCase, abc.LoaderTests):
2323

2424
"""Should have no issue importing a source module [basic]. And if there is
2525
a syntax error, it should raise a SyntaxError [syntax error].
@@ -177,6 +177,11 @@ def test_timestamp_overflow(self):
177177
# The pyc file was created.
178178
os.stat(compiled)
179179

180+
def test_unloadable(self):
181+
loader = machinery.SourceFileLoader('good name', {})
182+
with self.assertRaises(ImportError):
183+
loader.load_module('bad name')
184+
180185

181186
class BadBytecodeTest(unittest.TestCase):
182187

Lib/test/test_importlib/source/test_finder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import warnings
1414

1515

16-
class FinderTests(abc.FinderTests):
16+
class FinderTests(unittest.TestCase, abc.FinderTests):
1717

1818
"""For a top-level module, it should just be found directly in the
1919
directory being searched. This is true for a directory with source

0 commit comments

Comments
 (0)