aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_dataclasses.py
diff options
context:
space:
mode:
authorEric V. Smith <ericvsmith@users.noreply.github.com>2018-01-06 16:14:03 -0500
committerGitHub <noreply@github.com>2018-01-06 16:14:03 -0500
commited7d429ebb591f65cef558760fb4ebdc4fc8f8b0 (patch)
tree372d5745bb9d625b8d7a0be5a2bac802e40e5615 /Lib/test/test_dataclasses.py
parente7ba013d870012157f695ead7e3645c2828a7fc5 (diff)
downloadcpython-ed7d429ebb591f65cef558760fb4ebdc4fc8f8b0.tar.gz
cpython-ed7d429ebb591f65cef558760fb4ebdc4fc8f8b0.zip
bpo-32278: Allow dataclasses.make_dataclass() to omit type information. (gh-5115)
Diffstat (limited to 'Lib/test/test_dataclasses.py')
-rwxr-xr-xLib/test/test_dataclasses.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py
index fca384d8c3c..c44c53d039d 100755
--- a/Lib/test/test_dataclasses.py
+++ b/Lib/test/test_dataclasses.py
@@ -2033,6 +2033,20 @@ class TestCase(unittest.TestCase):
self.assertEqual(C.y, 10)
self.assertEqual(C.z, 20)
+ def test_helper_make_dataclass_no_types(self):
+ C = make_dataclass('Point', ['x', 'y', 'z'])
+ c = C(1, 2, 3)
+ self.assertEqual(vars(c), {'x': 1, 'y': 2, 'z': 3})
+ self.assertEqual(C.__annotations__, {'x': 'typing.Any',
+ 'y': 'typing.Any',
+ 'z': 'typing.Any'})
+
+ C = make_dataclass('Point', ['x', ('y', int), 'z'])
+ c = C(1, 2, 3)
+ self.assertEqual(vars(c), {'x': 1, 'y': 2, 'z': 3})
+ self.assertEqual(C.__annotations__, {'x': 'typing.Any',
+ 'y': int,
+ 'z': 'typing.Any'})
class TestDocString(unittest.TestCase):
def assertDocStrEqual(self, a, b):