Skip to content

Commit 37e6257

Browse files
committed
Add explanations to the test
1 parent f90762a commit 37e6257

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Lib/test/test_lazy_import/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,18 @@ def test_lazy_value_resolve(self):
210210
import test.test_lazy_import.data.lazy_get_value
211211
self.assertIn("test.test_lazy_import.data.basic2", sys.modules)
212212

213+
def test_lazy_import_type_exposed(self):
214+
"""LazyImportType should be exposed in types module."""
215+
self.assertHasAttr(types, 'LazyImportType')
216+
self.assertEqual(types.LazyImportType.__name__, 'lazy_import')
217+
218+
def test_lazy_import_type_cant_construct(self):
219+
"""LazyImportType should not be directly constructible."""
220+
self.assertRaises(TypeError, types.LazyImportType, {}, "module")
221+
213222
@support.requires_subprocess()
214-
def test_lazy_value_resolve_method_exists_if_not_called(self):
223+
def test_lazy_import_type_attributes_accessible(self):
224+
"""Regression test for GH-145453."""
215225
code = textwrap.dedent("""
216226
lazy import json
217227
print(globals()["json"].resolve)
@@ -224,15 +234,6 @@ def test_lazy_value_resolve_method_exists_if_not_called(self):
224234
self.assertEqual(result.returncode, 0, f"stdout: {result.stdout}, stderr: {result.stderr}")
225235
self.assertIn("<built-in method resolve of lazy_import object at", result.stdout)
226236

227-
def test_lazy_import_type_exposed(self):
228-
"""LazyImportType should be exposed in types module."""
229-
self.assertHasAttr(types, 'LazyImportType')
230-
self.assertEqual(types.LazyImportType.__name__, 'lazy_import')
231-
232-
def test_lazy_import_type_cant_construct(self):
233-
"""LazyImportType should not be directly constructible."""
234-
self.assertRaises(TypeError, types.LazyImportType, {}, "module")
235-
236237

237238
class SyntaxRestrictionTests(unittest.TestCase):
238239
"""Tests for syntax restrictions on lazy imports."""

0 commit comments

Comments
 (0)