diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-01-26 23:39:12 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-01-26 23:39:12 (GMT) |
commit | be59d1489bdf150e05e67a89cc772628af7e8fd6 (patch) | |
tree | 5e4677069edcb4609bf746163477f950e42b86c0 /Lib/test/test_ast.py | |
parent | 25219f596a069e8d4ed7114cd9b1bddc2a1de3b7 (diff) | |
download | cpython-be59d1489bdf150e05e67a89cc772628af7e8fd6.zip cpython-be59d1489bdf150e05e67a89cc772628af7e8fd6.tar.gz cpython-be59d1489bdf150e05e67a89cc772628af7e8fd6.tar.bz2 |
Issue #26146: enhance ast.Constant error message
Mention the name of the invalid type in error message of AST validation for
constants.
Suggestion made by Joseph Jevnik on a review.
Diffstat (limited to 'Lib/test/test_ast.py')
-rw-r--r-- | Lib/test/test_ast.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 6d6c9bd..57060d8 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -951,6 +951,12 @@ class ConstantTests(unittest.TestCase): exec(code, ns) return ns['x'] + def test_validation(self): + with self.assertRaises(TypeError) as cm: + self.compile_constant([1, 2, 3]) + self.assertEqual(str(cm.exception), + "got an invalid type in Constant: list") + def test_singletons(self): for const in (None, False, True, Ellipsis, b'', frozenset()): with self.subTest(const=const): |