Skip to content

Commit 4accf45

Browse files
committed
Issue #19596: Set untestable tests in test_importlib to None
to avoid reporting success on empty tests.
1 parent 30d8e16 commit 4accf45

7 files changed

Lines changed: 29 additions & 55 deletions

File tree

Lib/test/test_importlib/builtin/test_finder.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,11 @@ def test_module(self):
1616
found = machinery.BuiltinImporter.find_module(builtin_util.NAME)
1717
self.assertTrue(found)
1818

19-
def test_package(self):
20-
# Built-in modules cannot be a package.
21-
pass
19+
# Built-in modules cannot be a package.
20+
test_package = test_package_in_package = test_package_over_module = None
2221

23-
def test_module_in_package(self):
24-
# Built-in modules cannobt be in a package.
25-
pass
26-
27-
def test_package_in_package(self):
28-
# Built-in modules cannot be a package.
29-
pass
30-
31-
def test_package_over_module(self):
32-
# Built-in modules cannot be a package.
33-
pass
22+
# Built-in modules cannot be in a package.
23+
test_module_in_package = None
3424

3525
def test_failure(self):
3626
assert 'importlib' not in sys.builtin_module_names

Lib/test/test_importlib/builtin/test_loader.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,11 @@ def test_module(self):
3232
module = self.load_module(builtin_util.NAME)
3333
self.verify(module)
3434

35-
def test_package(self):
36-
# Built-in modules cannot be a package.
37-
pass
35+
# Built-in modules cannot be a package.
36+
test_package = test_lacking_parent = None
3837

39-
def test_lacking_parent(self):
40-
# Built-in modules cannot be a package.
41-
pass
42-
43-
def test_state_after_failure(self):
44-
# Not way to force an imoprt failure.
45-
pass
38+
# No way to force an import failure.
39+
test_state_after_failure = None
4640

4741
def test_module_reuse(self):
4842
# Test that the same module is used in a reload.

Lib/test/test_importlib/extension/test_finder.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,14 @@ def find_module(self, fullname):
1717
def test_module(self):
1818
self.assertTrue(self.find_module(util.NAME))
1919

20-
def test_package(self):
21-
# No extension module as an __init__ available for testing.
22-
pass
20+
# No extension module as an __init__ available for testing.
21+
test_package = test_package_in_package = None
2322

24-
def test_module_in_package(self):
25-
# No extension module in a package available for testing.
26-
pass
23+
# No extension module in a package available for testing.
24+
test_module_in_package = None
2725

28-
def test_package_in_package(self):
29-
# No extension module as an __init__ available for testing.
30-
pass
31-
32-
def test_package_over_module(self):
33-
# Extension modules cannot be an __init__ for a package.
34-
pass
26+
# Extension modules cannot be an __init__ for a package.
27+
test_package_over_module = None
3528

3629
def test_failure(self):
3730
self.assertIsNone(self.find_module('asdfjkl;'))

Lib/test/test_importlib/extension/test_loader.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,20 @@ def test_module(self):
3838
self.assertIsInstance(module.__loader__,
3939
machinery.ExtensionFileLoader)
4040

41-
def test_package(self):
42-
# No extension module as __init__ available for testing.
43-
pass
41+
# No extension module as __init__ available for testing.
42+
test_package = None
4443

45-
def test_lacking_parent(self):
46-
# No extension module in a package available for testing.
47-
pass
44+
# No extension module in a package available for testing.
45+
test_lacking_parent = None
4846

4947
def test_module_reuse(self):
5048
with util.uncache(ext_util.NAME):
5149
module1 = self.load_module(ext_util.NAME)
5250
module2 = self.load_module(ext_util.NAME)
5351
self.assertIs(module1, module2)
5452

55-
def test_state_after_failure(self):
56-
# No easy way to trigger a failure after a successful import.
57-
pass
53+
# No easy way to trigger a failure after a successful import.
54+
test_state_after_failure = None
5855

5956
def test_unloadable(self):
6057
name = 'asdfjkl;'

Lib/test/test_importlib/frozen/test_finder.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ def test_module_in_package(self):
2525
loader = self.find('__phello__.spam', ['__phello__'])
2626
self.assertTrue(hasattr(loader, 'load_module'))
2727

28-
def test_package_in_package(self):
29-
# No frozen package within another package to test with.
30-
pass
28+
# No frozen package within another package to test with.
29+
test_package_in_package = None
3130

32-
def test_package_over_module(self):
33-
# No easy way to test.
34-
pass
31+
# No easy way to test.
32+
test_package_over_module = None
3533

3634
def test_failure(self):
3735
loader = self.find('<not real>')

Lib/test/test_importlib/frozen/test_loader.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ def test_module_repr(self):
6565
self.assertEqual(repr(module),
6666
"<module '__hello__' (frozen)>")
6767

68-
def test_state_after_failure(self):
69-
# No way to trigger an error in a frozen module.
70-
pass
68+
# No way to trigger an error in a frozen module.
69+
test_state_after_failure = None
7170

7271
def test_unloadable(self):
7372
assert machinery.FrozenImporter.find_module('_not_real') is None

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ Library
5151
Tests
5252
-----
5353

54+
- Issue #19596: Set untestable tests in test_importlib to None to avoid
55+
reporting success on empty tests.
56+
5457
- Issue #19440: Clean up test_capi by removing an unnecessary __future__
5558
import, converting from test_main to unittest.main, and running the
5659
_testcapi module tests within a unittest TestCase.

0 commit comments

Comments
 (0)