diff options
author | Yury Selivanov <yury@magic.io> | 2019-12-09 09:54:20 -0500 |
---|---|---|
committer | Ćukasz Langa <lukasz@langa.pl> | 2019-12-09 15:54:20 +0100 |
commit | d219cc4180e7589807ebbef7421879f095e72a98 (patch) | |
tree | 851c77c76d776d146532fd16db6ccacbe7a1354e /Lib/test/test_dataclasses.py | |
parent | bba873e633f0f1e88ea12fb935cbd58faa77f976 (diff) | |
download | cpython-git-d219cc4180e7589807ebbef7421879f095e72a98.tar.gz |
bpo-34776: Fix dataclasses to support __future__ "annotations" mode (#9518)
Diffstat (limited to 'Lib/test/test_dataclasses.py')
-rw-r--r-- | Lib/test/test_dataclasses.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 238335e7d9..8f9fb2ce8c 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -10,6 +10,7 @@ import builtins import unittest from unittest.mock import Mock from typing import ClassVar, Any, List, Union, Tuple, Dict, Generic, TypeVar, Optional +from typing import get_type_hints from collections import deque, OrderedDict, namedtuple from functools import total_ordering @@ -2926,6 +2927,17 @@ class TestStringAnnotations(unittest.TestCase): # won't exist on the instance. self.assertNotIn('not_iv4', c.__dict__) + def test_text_annotations(self): + from test import dataclass_textanno + + self.assertEqual( + get_type_hints(dataclass_textanno.Bar), + {'foo': dataclass_textanno.Foo}) + self.assertEqual( + get_type_hints(dataclass_textanno.Bar.__init__), + {'foo': dataclass_textanno.Foo, + 'return': type(None)}) + class TestMakeDataclass(unittest.TestCase): def test_simple(self): |