diff options
author | RĂ©mi Lapeyre <remi.lapeyre@lenstra.fr> | 2020-05-24 21:12:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-24 21:12:57 (GMT) |
commit | c73914a562580ae72048876cb42ed8e76e2c83f9 (patch) | |
tree | c2530e91a3790121ef7d4a4650a0bdc7c91f1eeb /Lib/test/test_ast.py | |
parent | 59f5022b5d3e5fcc60ac61cc256b627decf8ee68 (diff) | |
download | cpython-c73914a562580ae72048876cb42ed8e76e2c83f9.zip cpython-c73914a562580ae72048876cb42ed8e76e2c83f9.tar.gz cpython-c73914a562580ae72048876cb42ed8e76e2c83f9.tar.bz2 |
bpo-36290: Fix keytword collision handling in AST node constructors (GH-12382)
Diffstat (limited to 'Lib/test/test_ast.py')
-rw-r--r-- | Lib/test/test_ast.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index e55d10b..3e9c8b5 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -402,6 +402,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) |