diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-12-09 16:07:54 (GMT) |
---|---|---|
committer | Ćukasz Langa <lukasz@langa.pl> | 2019-12-09 16:07:54 (GMT) |
commit | 66d7a5d58a88bce312bc4668f2cc54c9488c5bd8 (patch) | |
tree | 9deda59ede64d64fd7e74492da2cdc9d77a809fe /Lib/test/test_dataclasses.py | |
parent | a0078d9a3335a5e99afe97590fdcb8e2f526ed7b (diff) | |
download | cpython-66d7a5d58a88bce312bc4668f2cc54c9488c5bd8.zip cpython-66d7a5d58a88bce312bc4668f2cc54c9488c5bd8.tar.gz cpython-66d7a5d58a88bce312bc4668f2cc54c9488c5bd8.tar.bz2 |
bpo-34776: Fix dataclasses to support __future__ "annotations" mode (GH-9518) (#17532)
(cherry picked from commit d219cc4180e7589807ebbef7421879f095e72a98)
Co-authored-by: Yury Selivanov <yury@magic.io>
Diffstat (limited to 'Lib/test/test_dataclasses.py')
-rwxr-xr-x | 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 99086e5..2844845 100755 --- 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 @@ -2918,6 +2919,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): |