Commit 32425ed8 authored by Stefan Behnel's avatar Stefan Behnel

make syntax tests actually use Cython (and not Python)

parent 58fc7970
...@@ -72,6 +72,10 @@ def exec(code_string, l, g): ...@@ -72,6 +72,10 @@ def exec(code_string, l, g):
g.update(ns) g.update(ns)
def compile(code_string, module, level):
exec(code_string, {}, {})
class AsyncYieldFrom(object): class AsyncYieldFrom(object):
def __init__(self, obj): def __init__(self, obj):
self.obj = obj self.obj = obj
...@@ -461,7 +465,7 @@ class AsyncBadSyntaxTest(unittest.TestCase): ...@@ -461,7 +465,7 @@ class AsyncBadSyntaxTest(unittest.TestCase):
"""] """]
for code in samples: for code in samples:
with self.subTest(code=code), self.assertRaises(SyntaxError): with self.subTest(code=code), self.assertRaisesRegex(Errors.CompileError, '.'):
compile(code, "<test>", "exec") compile(code, "<test>", "exec")
def test_badsyntax_2(self): def test_badsyntax_2(self):
...@@ -496,17 +500,16 @@ class AsyncBadSyntaxTest(unittest.TestCase): ...@@ -496,17 +500,16 @@ class AsyncBadSyntaxTest(unittest.TestCase):
"""async = 1""", """async = 1""",
"""print(await=1)""" # FIXME: cannot currently request Py3 syntax in cython.inline()
#"""print(await=1)"""
] ]
for code in samples: for code in samples:
with self.subTest(code=code), self.assertWarnsRegex( with self.subTest(code=code): # , self.assertRaisesRegex(Errors.CompileError, '.'):
DeprecationWarning,
"'await' will become reserved keywords"):
compile(code, "<test>", "exec") compile(code, "<test>", "exec")
def test_badsyntax_3(self): def test_badsyntax_3(self):
with self.assertRaises(DeprecationWarning): #with self.assertRaises(DeprecationWarning):
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter("error") warnings.simplefilter("error")
compile("async = 1", "<test>", "exec") compile("async = 1", "<test>", "exec")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment