diff options
| author | Igor Davydenko <iam@igordavydenko.com> | 2015-08-26 17:19:06 +0300 |
|---|---|---|
| committer | Igor Davydenko <iam@igordavydenko.com> | 2015-08-26 17:19:06 +0300 |
| commit | c2086d643a519ce2eb1c266b4cf1550755b75d73 (patch) | |
| tree | e719d13a36db98627840e530ec388155d1c645c4 /pyflakes/test/test_other.py | |
| parent | 12653ca4dcf56f10ac041dae7a916e86343239ca (diff) | |
| download | pyflakes-c2086d643a519ce2eb1c266b4cf1550755b75d73.tar.gz | |
Support Python 3.5 async/await statements for Pyflakes.
Diffstat (limited to 'pyflakes/test/test_other.py')
| -rw-r--r-- | pyflakes/test/test_other.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/pyflakes/test/test_other.py b/pyflakes/test/test_other.py index 718d16f..384c4b3 100644 --- a/pyflakes/test/test_other.py +++ b/pyflakes/test/test_other.py @@ -988,3 +988,55 @@ class TestUnusedAssignment(TestCase): def test_returnOnly(self): """Do not crash on lone "return".""" self.flakes('return 2') + + +class TestAsyncStatements(TestCase): + + @skipIf(version_info < (3, 5), 'new in Python 3.5') + def test_asyncDef(self): + self.flakes(''' + async def bar(): + return 42 + ''') + + @skipIf(version_info < (3, 5), 'new in Python 3.5') + def test_asyncDefAwait(self): + self.flakes(''' + async def read_data(db): + await db.fetch('SELECT ...') + ''') + + @skipIf(version_info < (3, 5), 'new in Python 3.5') + def test_asyncDefUndefined(self): + self.flakes(''' + async def bar(): + return foo() + ''', m.UndefinedName) + + @skipIf(version_info < (3, 5), 'new in Python 3.5') + def test_asyncFor(self): + self.flakes(''' + async def read_data(db): + output = [] + async for row in db.cursor(): + output.append(row) + return output + ''') + + @skipIf(version_info < (3, 5), 'new in Python 3.5') + def test_asyncWith(self): + self.flakes(''' + async def commit(session, data): + async with session.transaction(): + await session.update(data) + ''') + + @skipIf(version_info < (3, 5), 'new in Python 3.5') + def test_asyncWithItem(self): + self.flakes(''' + async def commit(session, data): + async with session.transaction() as trans: + await trans.begin() + ... + await trans.end() + ''') |
