summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dataclasses.py
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2019-12-09 14:54:20 (GMT)
committerƁukasz Langa <lukasz@langa.pl>2019-12-09 14:54:20 (GMT)
commitd219cc4180e7589807ebbef7421879f095e72a98 (patch)
tree851c77c76d776d146532fd16db6ccacbe7a1354e /Lib/test/test_dataclasses.py
parentbba873e633f0f1e88ea12fb935cbd58faa77f976 (diff)
downloadcpython-d219cc4180e7589807ebbef7421879f095e72a98.zip
cpython-d219cc4180e7589807ebbef7421879f095e72a98.tar.gz
cpython-d219cc4180e7589807ebbef7421879f095e72a98.tar.bz2
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.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py
index 238335e..8f9fb2c 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):