diff options
Diffstat (limited to 'Lib/lib2to3/tests/test_parser.py')
-rw-r--r-- | Lib/lib2to3/tests/test_parser.py | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py index e4a0194..9a969e8 100644 --- a/Lib/lib2to3/tests/test_parser.py +++ b/Lib/lib2to3/tests/test_parser.py @@ -8,7 +8,7 @@ test_grammar.py files from both Python 2 and Python 3. # Testing imports from . import support -from .support import driver, test_dir +from .support import driver from test.support import verbose # Python imports @@ -134,6 +134,24 @@ class TestAsyncAwait(GrammarTest): """) self.validate("""async def foo(): + [i async for i in b] + """) + + self.validate("""async def foo(): + {i for i in b + async for i in a if await i + for b in i} + """) + + self.validate("""async def foo(): + [await i for i in b if await c] + """) + + self.validate("""async def foo(): + [ i for i in b if c] + """) + + self.validate("""async def foo(): def foo(): pass @@ -272,6 +290,36 @@ class TestFunctionAnnotations(GrammarTest): self.validate(s) +# Adapted from Python 3's Lib/test/test_grammar.py:GrammarTests.test_var_annot +class TestVarAnnotations(GrammarTest): + def test_1(self): + self.validate("var1: int = 5") + + def test_2(self): + self.validate("var2: [int, str]") + + def test_3(self): + self.validate("def f():\n" + " st: str = 'Hello'\n" + " a.b: int = (1, 2)\n" + " return st\n") + + def test_4(self): + self.validate("def fbad():\n" + " x: int\n" + " print(x)\n") + + def test_5(self): + self.validate("class C:\n" + " x: int\n" + " s: str = 'attr'\n" + " z = 2\n" + " def __init__(self, x):\n" + " self.x: int = x\n") + + def test_6(self): + self.validate("lst: List[int] = []") + class TestExcept(GrammarTest): def test_new(self): s = """ |