mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
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.
This commit is contained in:
parent
25219f596a
commit
be59d1489b
2 changed files with 9 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue