Skip to content

Commit 2b98d01

Browse files
committed
Use ensure_lazy_imports in the regression test
1 parent d86a8ef commit 2b98d01

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

Lib/test/test_dataclasses/__init__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import dataclasses # Needed for the string "dataclasses.InitVar[int]" to work as an annotation.
2828

2929
from test import support
30-
from test.support import cpython_only, import_helper, script_helper
30+
from test.support import cpython_only, import_helper
3131

3232
# Just any custom exception we can catch.
3333
class CustomError(Exception): pass
@@ -43,17 +43,17 @@ def test_lazy_import(self):
4343

4444
@cpython_only
4545
def test_slots_does_not_import_inspect(self):
46-
code = textwrap.dedent("""
47-
import sys
48-
from dataclasses import dataclass
49-
50-
@dataclass(slots=True)
46+
create_slotted_class = textwrap.dedent(
47+
"""
48+
@dataclasses.dataclass(slots=True)
5149
class C:
5250
x: int = 0
53-
54-
assert 'inspect' not in sys.modules
55-
""")
56-
script_helper.assert_python_ok("-c", code)
51+
"""
52+
)
53+
import_helper.ensure_lazy_imports(
54+
"dataclasses", {"inspect"},
55+
additional_code=create_slotted_class,
56+
)
5757

5858

5959
class TestCase(unittest.TestCase):

0 commit comments

Comments
 (0)