Skip to content

Commit 9a4624f

Browse files
committed
bpo-46425: Revert changes to importlib.metadata and importlib.resources tests
1 parent 6cacdb4 commit 9a4624f

File tree

10 files changed

+42
-41
lines changed

10 files changed

+42
-41
lines changed

Lib/test/test_importlib/test_compatibilty_files.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
wrap_spec,
99
)
1010

11-
from test.test_importlib.resources import util
11+
from . import util
1212

1313

1414
class CompatibilityFilesTests(unittest.TestCase):
@@ -102,5 +102,5 @@ def test_spec_path_joinpath(self):
102102
self.assertIsInstance(self.files / 'a', CompatibilityFiles.OrphanPath)
103103

104104

105-
if __name__ == '__main__':
106-
unittest.main()
105+
# This module is not suitable to be executed directly.
106+
# Use appropriate test tool.

Lib/test/test_importlib/test_contents.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import unittest
22
from importlib import resources
33

4-
from test.test_importlib import data01
5-
from test.test_importlib.resources import util
4+
from . import data01
5+
from .resources import util
66

77

88
class ContentsTests:
@@ -38,10 +38,10 @@ class ContentsNamespaceTests(ContentsTests, unittest.TestCase):
3838
}
3939

4040
def setUp(self):
41-
from test.test_importlib import namespacedata01
41+
from . import namespacedata01
4242

4343
self.data = namespacedata01
4444

4545

46-
if __name__ == '__main__':
47-
unittest.main()
46+
# This module is not suitable to be executed directly.
47+
# Use appropriate test tool.

Lib/test/test_importlib/test_files.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
from importlib import resources
55
from importlib.abc import Traversable
6-
from test.test_importlib import data01
7-
from test.test_importlib.resources import util
6+
from . import data01
7+
from .resources import util
88

99

1010
class FilesTests:
@@ -37,10 +37,10 @@ class OpenZipTests(FilesTests, util.ZipSetup, unittest.TestCase):
3737

3838
class OpenNamespaceTests(FilesTests, unittest.TestCase):
3939
def setUp(self):
40-
from test.test_importlib import namespacedata01
40+
from . import namespacedata01
4141

4242
self.data = namespacedata01
4343

4444

45-
if __name__ == '__main__':
46-
unittest.main()
45+
# This module is not suitable to be executed directly.
46+
# Use appropriate test tool.

Lib/test/test_importlib/test_main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
try:
1010
import pyfakefs.fake_filesystem_unittest as ffs
1111
except ImportError:
12-
from test.test_importlib.stubs import fake_filesystem_unittest as ffs
12+
from .stubs import fake_filesystem_unittest as ffs
1313

14-
from test.test_importlib import fixtures
14+
from . import fixtures
1515
from importlib.metadata import (
1616
Distribution,
1717
EntryPoint,
@@ -317,5 +317,5 @@ def test_packages_distributions_neither_toplevel_nor_files(self):
317317
packages_distributions()
318318

319319

320-
if __name__ == '__main__':
321-
unittest.main()
320+
# This module is not suitable to be executed directly.
321+
# Use appropriate test tool.

Lib/test/test_importlib/test_metadata_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import importlib
66
import contextlib
77

8-
from test.test_importlib import fixtures
8+
from . import fixtures
99
from importlib.metadata import (
1010
Distribution,
1111
PackageNotFoundError,
@@ -315,5 +315,5 @@ def test_invalidate_cache(self):
315315
importlib.invalidate_caches()
316316

317317

318-
if __name__ == '__main__':
319-
unittest.main()
318+
# This module is not suitable to be executed directly.
319+
# Use appropriate test tool.

Lib/test/test_importlib/test_open.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import unittest
22

33
from importlib import resources
4-
from test.test_importlib import data01
5-
from test.test_importlib.resources import util
4+
from . import data01
5+
from .resources import util
66

77

88
class CommonBinaryTests(util.CommonTests, unittest.TestCase):
@@ -68,7 +68,7 @@ def setUp(self):
6868

6969
class OpenDiskNamespaceTests(OpenTests, unittest.TestCase):
7070
def setUp(self):
71-
from test.test_importlib import namespacedata01
71+
from . import namespacedata01
7272

7373
self.data = namespacedata01
7474

@@ -77,5 +77,5 @@ class OpenZipTests(OpenTests, util.ZipSetup, unittest.TestCase):
7777
pass
7878

7979

80-
if __name__ == '__main__':
81-
unittest.main()
80+
# This module is not suitable to be executed directly.
81+
# Use appropriate test tool.

Lib/test/test_importlib/test_path.py

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

44
from importlib import resources
5-
from test.test_importlib import data01
6-
from test.test_importlib.resources import util
5+
from . import data01
6+
from .resources import util
77

88

99
class CommonTests(util.CommonTests, unittest.TestCase):
@@ -58,5 +58,5 @@ def test_remove_in_context_manager(self):
5858
path.unlink()
5959

6060

61-
if __name__ == '__main__':
62-
unittest.main()
61+
# This module is not suitable to be executed directly.
62+
# Use appropriate test tool.

Lib/test/test_importlib/test_read.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import unittest
22

33
from importlib import import_module, resources
4-
from test.test_importlib import data01
5-
from test.test_importlib.resources import util
4+
from . import data01
5+
from .resources import util
66

77

88
class CommonBinaryTests(util.CommonTests, unittest.TestCase):
@@ -66,10 +66,10 @@ def test_read_submodule_resource_by_name(self):
6666

6767
class ReadNamespaceTests(ReadTests, unittest.TestCase):
6868
def setUp(self):
69-
from test.test_importlib import namespacedata01
69+
from . import namespacedata01
7070

7171
self.data = namespacedata01
7272

7373

74-
if __name__ == '__main__':
75-
unittest.main()
74+
# This module is not suitable to be executed directly.
75+
# Use appropriate test tool.

Lib/test/test_importlib/test_resource.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import uuid
44
import pathlib
55

6-
from test.test_importlib import data01, zipdata01, zipdata02
7-
from test.test_importlib.resources import util
6+
from . import data01
7+
from . import zipdata01, zipdata02
8+
from .resources import util
89
from importlib import resources, import_module
910
from test.support import import_helper
1011
from test.support.os_helper import unlink
@@ -247,5 +248,5 @@ def test_submodule_contents_by_name(self):
247248
self.assertEqual(contents, {'binary.file', 'utf-8.file', 'utf-16.file'})
248249

249250

250-
if __name__ == '__main__':
251-
unittest.main()
251+
# This module is not suitable to be executed directly.
252+
# Use appropriate test tool.

Lib/test/test_importlib/test_zip.py

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

4-
from test.test_importlib import fixtures
4+
from . import fixtures
55
from importlib.metadata import (
66
PackageNotFoundError,
77
distribution,
@@ -61,5 +61,5 @@ def test_normalized_name(self):
6161
dist = distribution('example')
6262
assert dist._normalized_name == 'example'
6363

64-
if __name__ == '__main__':
65-
unittest.main()
64+
# This module is not suitable to be executed directly.
65+
# Use appropriate test tool.

0 commit comments

Comments
 (0)