From 01ee12ba35a333e8a6a25c4153c4a21838e9585c Mon Sep 17 00:00:00 2001 From: Augusto Hack Date: Sun, 2 Jun 2019 23:14:48 -0300 Subject: bpo-33569 Preserve type information with dataclasses.InitVar (GH-8927) --- Lib/test/test_dataclasses.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Lib/test/test_dataclasses.py') diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 867210688f5..53e8443c2ad 100755 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -1097,6 +1097,12 @@ class TestCase(unittest.TestCase): c = C(init_param=10) self.assertEqual(c.x, 20) + def test_init_var_preserve_type(self): + self.assertEqual(InitVar[int].type, int) + + # Make sure the repr is correct. + self.assertEqual(repr(InitVar[int]), 'dataclasses.InitVar[int]') + def test_init_var_inheritance(self): # Note that this deliberately tests that a dataclass need not # have a __post_init__ function if it has an InitVar field. -- cgit v1.2.3