Skip to content

Commit f0a4146

Browse files
committed
Add test for docstring of recursive dataclass
1 parent 820e28c commit f0a4146

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Lib/test/test_dataclasses/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TestImportTime(unittest.TestCase):
3838
@cpython_only
3939
def test_lazy_import(self):
4040
import_helper.ensure_lazy_imports(
41-
"dataclasses", {"inspect"}
41+
"dataclasses", {"inspect", "re", "copy"}
4242
)
4343

4444

@@ -2312,6 +2312,13 @@ class C:
23122312

23132313
self.assertDocStrEqual(C.__doc__, "C(x:int)")
23142314

2315+
def test_docstring_recursive(self):
2316+
@dataclass()
2317+
class C:
2318+
x: list[C]
2319+
2320+
self.assertDocStrEqual(C.__doc__, "C(x:list[test.test_dataclasses.TestDocString.test_docstring_recursive.<locals>.C])")
2321+
23152322
def test_docstring_one_field(self):
23162323
@dataclass
23172324
class C:

0 commit comments

Comments
 (0)