8000 gh-118761: Add test_lazy_import for more modules by danielhollas · Pull Request #133057 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-118761: Add test_lazy_import for more modules #133057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 5, 2025
Prev Previous commit
Next Next commit
Review
  • Loading branch information
danielhollas committed May 4, 2025
commit 875e0bdd6c20bb3194b66c2c5dc1df169581caf8
8 changes: 4 additions & 4 deletions Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,10 +1275,6 @@ class Holiday(date, Enum):
IDES_OF_MARCH = 2013, 3, 15
self.Holiday = Holiday

@cpython_only
def test_lazy_import(self):
ensure_lazy_imports("enum", {"functools", "warnings", "inspect", "re"})

def test_bool(self):
# plain Enum members are always True
class Logic(Enum):
Expand Down Expand Up @@ -5293,6 +5289,10 @@ class MiscTestCase(unittest.TestCase):
def test__all__(self):
support.check__all__(self, enum, not_exported={'bin', 'show_flag_values'})

@cpython_only
def test_lazy_import(self):
ensure_lazy_imports("enum", {"functools", "warnings", "inspect", "re"})

def test_doc_1(self):
class Single(Enum):
ONE = 1
Expand Down
10 changes: 6 additions & 4 deletions Lib/test/test_pathlib/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def test_is_notimplemented(self):
self.assertTrue(isinstance(pathlib.UnsupportedOperation(), NotImplementedError))


class TestImportTime(unittest.TestCase):
@cpython_only
def test_lazy_import(self):
import_helper.ensure_lazy_imports("pathlib", {"shutil"})


#
# Tests for the pure classes.
#
Expand Down Expand Up @@ -130,10 +136,6 @@ class StrSubclass(str):
for part in p.parts:
self.assertIs(type(part), str)

@cpython_only
def test_lazy_import(self):
import_helper.ensure_lazy_imports("pathlib", {"shutil"})

def test_str_subclass_common(self):
self._check_str_subclass('')
self._check_str_subclass('.')
Expand Down
0