summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-05-24 21:31:47 (GMT)
committerGitHub <noreply@github.com>2020-05-24 21:31:47 (GMT)
commit907ee1f14aaf587683ced44818c5a1d1cabf4174 (patch)
tree9aa24db133b55bc1adbaa5e63761b89bb75c769c /Lib/test
parent1ae0fd87a072426e35ff84dc6d1b2759d9ebee70 (diff)
downloadcpython-907ee1f14aaf587683ced44818c5a1d1cabf4174.zip
cpython-907ee1f14aaf587683ced44818c5a1d1cabf4174.tar.gz
cpython-907ee1f14aaf587683ced44818c5a1d1cabf4174.tar.bz2
bpo-36290: Fix keytword collision handling in AST node constructors (GH-12382)
(cherry picked from commit c73914a562580ae72048876cb42ed8e76e2c83f9) Co-authored-by: Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_ast.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 8887558..486f2aa 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -387,6 +387,15 @@ class AST_Tests(unittest.TestCase):
self.assertRaises(TypeError, ast.Num, 1, None, 2)
self.assertRaises(TypeError, ast.Num, 1, None, 2, lineno=0)
+ # Arbitrary keyword arguments are supported
+ self.assertEqual(ast.Constant(1, foo='bar').foo, 'bar')
+ self.assertEqual(ast.Num(1, foo='bar').foo, 'bar')
+
+ with self.assertRaisesRegex(TypeError, "Num got multiple values for argument 'n'"):
+ ast.Num(1, n=2)
+ with self.assertRaisesRegex(TypeError, "Constant got multiple values for argument 'value'"):
+ ast.Constant(1, value=2)
+
self.assertEqual(ast.Num(42).n, 42)
self.assertEqual(ast.Num(4.25).n, 4.25)
self.assertEqual(ast.Num(4.25j).n, 4.25j)