File tree Expand file tree Collapse file tree
Lib/test/test_dataclasses Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727import dataclasses # Needed for the string "dataclasses.InitVar[int]" to work as an annotation.
2828
2929from 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.
3333class 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
5959class TestCase (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments