forked from aio-libs/aiohttp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing app.loop in startup hook during test
Fixes aio-libs#2060
- Loading branch information
Showing
3 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix missing app.loop on startup hooks during tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import asyncio | ||
from aiohttp import web | ||
from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop | ||
|
||
|
||
class TestCase(AioHTTPTestCase): | ||
@asyncio.coroutine | ||
def get_application(self): | ||
app = web.Application() | ||
app.on_startup.append(self.on_startup_hook) | ||
return app | ||
|
||
@asyncio.coroutine | ||
def on_startup_hook(self, app): | ||
self.startup_loop = app.loop | ||
|
||
@unittest_run_loop | ||
@asyncio.coroutine | ||
def test_on_startup_hook(self): | ||
assert self.startup_loop is not None |