summaryrefslogtreecommitdiff
path: root/pyflakes/test/test_other.py
diff options
context:
space:
mode:
authorIgor Davydenko <iam@igordavydenko.com>2015-08-26 17:19:06 +0300
committerIgor Davydenko <iam@igordavydenko.com>2015-08-26 17:19:06 +0300
commitc2086d643a519ce2eb1c266b4cf1550755b75d73 (patch)
treee719d13a36db98627840e530ec388155d1c645c4 /pyflakes/test/test_other.py
parent12653ca4dcf56f10ac041dae7a916e86343239ca (diff)
downloadpyflakes-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.py52
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()
+ ''')