diff --git a/aiohttp/test_utils.py b/aiohttp/test_utils.py index bb6b97254d1..08bdd4cb6df 100644 --- a/aiohttp/test_utils.py +++ b/aiohttp/test_utils.py @@ -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() diff --git a/tests/conftest.py b/tests/conftest.py index 429fc743705..23fd1c3c2c2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,7 +5,7 @@ import pytest -pytest_plugins = 'aiohttp.pytest_plugin' +pytest_plugins = ['aiohttp.pytest_plugin', 'pytester'] _LoggingWatcher = collections.namedtuple("_LoggingWatcher", diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index b4264cf44d0..af6c16c9cc1 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -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*"])