summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_ast.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index a9d55c0632..e3aa5b170a 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -362,6 +362,20 @@ class AST_Tests(unittest.TestCase):
ast2 = mod.loads(mod.dumps(ast, protocol))
self.assertEqual(to_tuple(ast2), to_tuple(ast))
+ def test_invalid_identitifer(self):
+ m = ast.Module([ast.Expr(ast.Name(u"x", 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(43))])
+ ast.fix_missing_locations(m)
+ with self.assertRaises(TypeError) as cm:
+ compile(m, "<test>", "exec")
+ self.assertIn("string must be of type str or uni", str(cm.exception))
+
class ASTHelpers_Test(unittest.TestCase):