diff options
author | Raymond Hettinger <python@rcn.com> | 2010-10-08 00:47:45 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-10-08 00:47:45 (GMT) |
commit | bc95973b51abadc84960e7836ce313f12cf515cf (patch) | |
tree | 71fed836ea6caa2f4f61f2041f2b1570a94de6f5 /Lib/test/test_ast.py | |
parent | 4f3abb0f091b14e09d257ee4eb40632471177d6d (diff) | |
download | cpython-bc95973b51abadc84960e7836ce313f12cf515cf.zip cpython-bc95973b51abadc84960e7836ce313f12cf515cf.tar.gz cpython-bc95973b51abadc84960e7836ce313f12cf515cf.tar.bz2 |
Fix handling on negative numbers in ast.literal_eval().
Diffstat (limited to 'Lib/test/test_ast.py')
-rw-r--r-- | Lib/test/test_ast.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index f00a415..b5295ef 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -288,12 +288,14 @@ class ASTHelpers_Test(unittest.TestCase): self.assertEqual(ast.literal_eval('{1, 2, 3}'), {1, 2, 3}) self.assertEqual(ast.literal_eval('b"hi"'), b"hi") self.assertRaises(ValueError, ast.literal_eval, 'foo()') + self.assertEqual(ast.literal_eval('-6'), -6) + self.assertEqual(ast.literal_eval('-6j+3'), 3-6j) + self.assertEqual(ast.literal_eval('3.25'), 3.25) def test_literal_eval_issue4907(self): self.assertEqual(ast.literal_eval('2j'), 2j) self.assertEqual(ast.literal_eval('10 + 2j'), 10 + 2j) self.assertEqual(ast.literal_eval('1.5 - 2j'), 1.5 - 2j) - self.assertRaises(ValueError, ast.literal_eval, '2 + (3 + 4j)') def test_main(): |