Skip to content

Commit

Permalink
Display a hint if you forget to define get_application()
Browse files Browse the repository at this point in the history
  • Loading branch information
cecton committed Jul 30, 2017
1 parent 8071947 commit 5219adf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def get_app(self):
Use .get_application() coroutine instead
"""
pass # pragma: no cover
raise RuntimeError("Did you forget to define get_application()?")

def setUp(self):
self.loop = setup_test_loop()
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest


pytest_plugins = 'aiohttp.pytest_plugin'
pytest_plugins = ['aiohttp.pytest_plugin', 'pytester']


_LoggingWatcher = collections.namedtuple("_LoggingWatcher",
Expand Down
15 changes: 15 additions & 0 deletions tests/test_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,18 @@ def test_no_custom_client_session(test_client, loop):
app = _create_example_app()
with _TestClient(_TestServer(app, loop=loop), loop=loop) as client:
assert isinstance(client.session, aiohttp.ClientSession)


def test_testcase_no_app(testdir, loop):
testdir.makepyfile(
"""
from aiohttp.test_utils import AioHTTPTestCase
class InvalidTestCase(AioHTTPTestCase):
def test_noop(self):
pass
""")
result = testdir.runpytest()
result.assert_outcomes(failed=1)
result.stdout.fnmatch_lines(["*RuntimeError*"])

0 comments on commit 5219adf

Please sign in to comment.