summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dataclasses.py
diff options
context:
space:
mode:
authorAugusto Hack <hack.augusto@gmail.com>2019-06-03 02:14:48 (GMT)
committerEric V. Smith <ericvsmith@users.noreply.github.com>2019-06-03 02:14:48 (GMT)
commit01ee12ba35a333e8a6a25c4153c4a21838e9585c (patch)
tree2bfae29ffb6dd7c2c3b94e90d6f4c4294b7be3e9 /Lib/test/test_dataclasses.py
parent0025350294959594e7f57aef4fc9579c77a0ed1c (diff)
downloadcpython-01ee12ba35a333e8a6a25c4153c4a21838e9585c.zip
cpython-01ee12ba35a333e8a6a25c4153c4a21838e9585c.tar.gz
cpython-01ee12ba35a333e8a6a25c4153c4a21838e9585c.tar.bz2
bpo-33569 Preserve type information with dataclasses.InitVar (GH-8927)
Diffstat (limited to 'Lib/test/test_dataclasses.py')
-rwxr-xr-xLib/test/test_dataclasses.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py
index 8672106..53e8443 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.