From 9a7d853088d28bf28b2b59033c556225a2402e11 Mon Sep 17 00:00:00 2001 From: Tim Hughes Date: Sun, 11 Feb 2018 08:53:03 +0000 Subject: [PATCH] fixes #2717 Makes unittest example work (#2718) --- CHANGES/2717.doc | 1 + docs/testing.rst | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 CHANGES/2717.doc diff --git a/CHANGES/2717.doc b/CHANGES/2717.doc new file mode 100644 index 00000000000..0673376659a --- /dev/null +++ b/CHANGES/2717.doc @@ -0,0 +1 @@ +Fix issue with unittest example not compiling in testing docs. diff --git a/docs/testing.rst b/docs/testing.rst index e63c2db3634..01a3e4a7ba0 100644 --- a/docs/testing.rst +++ b/docs/testing.rst @@ -246,7 +246,12 @@ functionality, the AioHTTPTestCase is provided:: """ Override the get_app method to return your application. """ - return web.Application() + async def hello(request): + return web.Response(text='Hello, world') + + app = web.Application() + app.router.add_get('/', hello) + return app # the unittest_run_loop decorator can be used in tandem with # the AioHTTPTestCase to simplify running @@ -259,10 +264,10 @@ functionality, the AioHTTPTestCase is provided:: assert "Hello, world" in text # a vanilla example - def test_example(self): + def test_example_vanilla(self): async def test_get_route(): - url = root + "/" - resp = await self.client.request("GET", url, loop=loop) + url = "/" + resp = await self.client.request("GET", url) assert resp.status == 200 text = await resp.text() assert "Hello, world" in text