|
|
97147d |
From eb4f5a4bb28f8260d4edc32969e838d9abace051 Mon Sep 17 00:00:00 2001
|
|
|
97147d |
From: Andrew Svetlov <andrew.svetlov@gmail.com>
|
|
|
97147d |
Date: Mon, 15 Oct 2018 21:32:48 +0300
|
|
|
97147d |
Subject: [PATCH] Fix tests
|
|
|
97147d |
|
|
|
97147d |
---
|
|
|
97147d |
tests/integration/test_real_browser.py | 18 ++++++++----------
|
|
|
97147d |
tests/unit/test_cors_config.py | 5 ++---
|
|
|
97147d |
2 files changed, 10 insertions(+), 13 deletions(-)
|
|
|
97147d |
|
|
|
97147d |
diff --git a/tests/integration/test_real_browser.py b/tests/integration/test_real_browser.py
|
|
|
97147d |
index a5c9030..5dff79a 100644
|
|
|
97147d |
--- a/tests/integration/test_real_browser.py
|
|
|
97147d |
+++ b/tests/integration/test_real_browser.py
|
|
|
97147d |
@@ -193,22 +193,20 @@ class ResourceView(web.View, CorsViewMixin):
|
|
|
97147d |
|
|
|
97147d |
# Start servers.
|
|
|
97147d |
for server_name, server_descr in self.servers.items():
|
|
|
97147d |
- handler = server_descr.app.make_handler()
|
|
|
97147d |
- server = await self.loop.create_server(
|
|
|
97147d |
- handler,
|
|
|
97147d |
- sock=server_sockets[server_name])
|
|
|
97147d |
- server_descr.handler = handler
|
|
|
97147d |
- server_descr.server = server
|
|
|
97147d |
+ runner = web.AppRunner(server_descr.app)
|
|
|
97147d |
+ await runner.setup()
|
|
|
97147d |
+ site = web.SockSite(runner, server_sockets[server_name])
|
|
|
97147d |
+ await site.start()
|
|
|
97147d |
+ server_descr.runner = runner
|
|
|
97147d |
|
|
|
97147d |
self._logger.info("Started server '%s' at '%s'",
|
|
|
97147d |
server_name, server_descr.url)
|
|
|
97147d |
|
|
|
97147d |
async def stop_servers(self):
|
|
|
97147d |
for server_descr in self.servers.values():
|
|
|
97147d |
- server_descr.server.close()
|
|
|
97147d |
- await server_descr.handler.shutdown()
|
|
|
97147d |
- await server_descr.server.wait_closed()
|
|
|
97147d |
- await server_descr.app.cleanup()
|
|
|
97147d |
+ runner = server_descr.runner
|
|
|
97147d |
+ await runner.shutdown()
|
|
|
97147d |
+ await runner.cleanup()
|
|
|
97147d |
|
|
|
97147d |
self.servers = {}
|
|
|
97147d |
|
|
|
97147d |
diff --git a/tests/unit/test_cors_config.py b/tests/unit/test_cors_config.py
|
|
|
97147d |
index 5b8d8f3..817410e 100644
|
|
|
97147d |
--- a/tests/unit/test_cors_config.py
|
|
|
97147d |
+++ b/tests/unit/test_cors_config.py
|
|
|
97147d |
@@ -58,11 +58,10 @@ def options_route(app):
|
|
|
97147d |
"OPTIONS", "/options_path", _handler)
|
|
|
97147d |
|
|
|
97147d |
|
|
|
97147d |
-def test_add_options_route(cors, options_route):
|
|
|
97147d |
+def test_add_options_route(app, cors, options_route):
|
|
|
97147d |
"""Test configuring OPTIONS route"""
|
|
|
97147d |
-
|
|
|
97147d |
with pytest.raises(ValueError,
|
|
|
97147d |
- match="/options_path already has OPTIONS handler"):
|
|
|
97147d |
+ match="already has OPTIONS handler"):
|
|
|
97147d |
cors.add(options_route.resource)
|
|
|
97147d |
|
|
|
97147d |
|