diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-07-22 15:55:02 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-07-22 15:55:02 (GMT) |
commit | 86f088e8e50632ee28bbf2366d48b2e503244fcd (patch) | |
tree | fa658c23d22321616222a6a66715046702382090 /Lib/test/test_ast.py | |
parent | db57e8d186f028cdf472175f48b4aed99b32c972 (diff) | |
parent | 2193d2b72bc942a0c0b489a9c2759a6aefbeecdf (diff) | |
download | cpython-86f088e8e50632ee28bbf2366d48b2e503244fcd.zip cpython-86f088e8e50632ee28bbf2366d48b2e503244fcd.tar.gz cpython-86f088e8e50632ee28bbf2366d48b2e503244fcd.tar.bz2 |
merge 3.2
Diffstat (limited to 'Lib/test/test_ast.py')
-rw-r--r-- | Lib/test/test_ast.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 04e8308..77839c2 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -367,6 +367,20 @@ class AST_Tests(unittest.TestCase): compile(m, "<test>", "exec") self.assertIn("but got <_ast.expr", str(cm.exception)) + def test_invalid_identitifer(self): + m = ast.Module([ast.Expr(ast.Name(42, ast.Load()))]) + ast.fix_missing_locations(m) + with self.assertRaises(TypeError) as cm: + compile(m, "<test>", "exec") + self.assertIn("identifier must be of type str", str(cm.exception)) + + def test_invalid_string(self): + m = ast.Module([ast.Expr(ast.Str(42))]) + ast.fix_missing_locations(m) + with self.assertRaises(TypeError) as cm: + compile(m, "<test>", "exec") + self.assertIn("string must be of type str", str(cm.exception)) + class ASTHelpers_Test(unittest.TestCase): |