File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,13 @@ def _validate(self):
8787 """
8888 pass
8989
90+ def __await__ (self ):
91+ """
92+ If the user doesn't explicity call .run(), proxy to it as a
93+ convenience.
94+ """
95+ return self .run ().__await__ ()
96+
9097 async def run (self , in_pool = True ):
9198 self ._validate ()
9299
Original file line number Diff line number Diff line change 1+ import asyncio
2+
3+ from ..base import DBTestCase
4+ from ..example_project .tables import Band
5+
6+
7+ class TestAwait (DBTestCase ):
8+ def test_await (self ):
9+ """
10+ Test awaiting a query directly - it should proxy to Query.run().
11+ """
12+
13+ async def get_all ():
14+ return await Band .select ()
15+
16+ response = asyncio .run (get_all ())
17+
18+ self .assertIsInstance (response , list )
You can’t perform that action at this time.
0 commit comments