◐ Shell
clean mode source ↗

bpo-46425: revert changes to `importlib.metadata` and `importlib.resources` tests by sobolevn · Pull Request #30800 · python/cpython

6 changes: 3 additions & 3 deletions Lib/test/test_importlib/test_compatibilty_files.py

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
wrap_spec,
)

from test.test_importlib.resources import util
from . import util


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


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

jaraco marked this conversation as resolved.

10 changes: 5 additions & 5 deletions Lib/test/test_importlib/test_contents.py

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest
from importlib import resources

from test.test_importlib import data01
from test.test_importlib.resources import util
from . import data01
from .resources import util


class ContentsTests:
Expand Down Expand Up @@ -38,10 +38,10 @@ class ContentsNamespaceTests(ContentsTests, unittest.TestCase):
}

def setUp(self):
from test.test_importlib import namespacedata01
from . import namespacedata01

self.data = namespacedata01


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

10 changes: 5 additions & 5 deletions Lib/test/test_importlib/test_files.py

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from importlib import resources
from importlib.abc import Traversable
from test.test_importlib import data01
from test.test_importlib.resources import util
from . import data01
from .resources import util


class FilesTests:
Expand Down Expand Up @@ -37,10 +37,10 @@ class OpenZipTests(FilesTests, util.ZipSetup, unittest.TestCase):

class OpenNamespaceTests(FilesTests, unittest.TestCase):
def setUp(self):
from test.test_importlib import namespacedata01
from . import namespacedata01

self.data = namespacedata01


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

8 changes: 4 additions & 4 deletions Lib/test/test_importlib/test_main.py

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
try:
import pyfakefs.fake_filesystem_unittest as ffs
except ImportError:
from test.test_importlib.stubs import fake_filesystem_unittest as ffs
from .stubs import fake_filesystem_unittest as ffs

from test.test_importlib import fixtures
from . import fixtures
from importlib.metadata import (
Distribution,
EntryPoint,
Expand Down Expand Up @@ -317,5 +317,5 @@ def test_packages_distributions_neither_toplevel_nor_files(self):
packages_distributions()


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

6 changes: 3 additions & 3 deletions Lib/test/test_importlib/test_metadata_api.py

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import importlib
import contextlib

from test.test_importlib import fixtures
from . import fixtures
from importlib.metadata import (
Distribution,
PackageNotFoundError,
Expand Down Expand Up @@ -315,5 +315,5 @@ def test_invalidate_cache(self):
importlib.invalidate_caches()


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

10 changes: 5 additions & 5 deletions Lib/test/test_importlib/test_open.py

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest

from importlib import resources
from test.test_importlib import data01
from test.test_importlib.resources import util
from . import data01
from .resources import util


class CommonBinaryTests(util.CommonTests, unittest.TestCase):
Expand Down Expand Up @@ -68,7 +68,7 @@ def setUp(self):

class OpenDiskNamespaceTests(OpenTests, unittest.TestCase):
def setUp(self):
from test.test_importlib import namespacedata01
from . import namespacedata01

self.data = namespacedata01

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


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

8 changes: 4 additions & 4 deletions Lib/test/test_importlib/test_path.py

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import unittest

from importlib import resources
from test.test_importlib import data01
from test.test_importlib.resources import util
from . import data01
from .resources import util


class CommonTests(util.CommonTests, unittest.TestCase):
Expand Down Expand Up @@ -58,5 +58,5 @@ def test_remove_in_context_manager(self):
path.unlink()


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

10 changes: 5 additions & 5 deletions Lib/test/test_importlib/test_read.py

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest

from importlib import import_module, resources
from test.test_importlib import data01
from test.test_importlib.resources import util
from . import data01
from .resources import util


class CommonBinaryTests(util.CommonTests, unittest.TestCase):
Expand Down Expand Up @@ -66,10 +66,10 @@ def test_read_submodule_resource_by_name(self):

class ReadNamespaceTests(ReadTests, unittest.TestCase):
def setUp(self):
from test.test_importlib import namespacedata01
from . import namespacedata01

self.data = namespacedata01


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

9 changes: 5 additions & 4 deletions Lib/test/test_importlib/test_resource.py

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import uuid
import pathlib

from test.test_importlib import data01, zipdata01, zipdata02
from test.test_importlib.resources import util
from . import data01
from . import zipdata01, zipdata02
from .resources import util
from importlib import resources, import_module
from test.support import import_helper
from test.support.os_helper import unlink
Expand Down Expand Up @@ -247,5 +248,5 @@ def test_submodule_contents_by_name(self):
self.assertEqual(contents, {'binary.file', 'utf-8.file', 'utf-16.file'})


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

6 changes: 3 additions & 3 deletions Lib/test/test_importlib/test_zip.py

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import unittest

from test.test_importlib import fixtures
from . import fixtures
from importlib.metadata import (
PackageNotFoundError,
distribution,
Expand Down Expand Up @@ -61,5 +61,5 @@ def test_normalized_name(self):
dist = distribution('example')
assert dist._normalized_name == 'example'

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