1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-12 19:38:57 +00:00

Avoid tasks lost during tests creating noisy warnings

This commit is contained in:
Julien Duponchelle 2016-09-02 14:09:01 +02:00
parent 2d86a7fdcf
commit 0afd7b78b7
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 16 additions and 19 deletions

View File

@ -377,7 +377,7 @@ class Compute:
try:
self._ws = yield from self._session().ws_connect(self._getUrl("/notifications/ws"), auth=self._auth)
except aiohttp.errors.WSServerHandshakeError:
self._ws
self._ws = None
while self._ws is not None:
try:
response = yield from self._ws.receive()

View File

@ -55,17 +55,14 @@ def restore_original_path():
os.environ["PATH"] = tempfile.mkdtemp()
@pytest.fixture(scope="session")
@pytest.yield_fixture(scope="session")
def loop(request):
"""Return an event loop and destroy it at the end of test"""
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop) # Replace main loop to avoid conflict between tests
def tear_down():
loop.close()
asyncio.set_event_loop(None)
request.addfinalizer(tear_down)
return loop
yield loop
#loop.close()
asyncio.set_event_loop(None)
def _get_unused_port():
@ -78,8 +75,8 @@ def _get_unused_port():
return port
@pytest.fixture
def http_server(request, loop, port_manager, monkeypatch):
@pytest.yield_fixture
def http_server(request, loop, port_manager, monkeypatch, controller):
"""A GNS3 server"""
app = web.Application()
@ -102,15 +99,15 @@ def http_server(request, loop, port_manager, monkeypatch):
else:
break
def tear_down():
for module in MODULES:
instance = module.instance()
monkeypatch.setattr('gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.close', lambda self: True)
loop.run_until_complete(instance.unload())
srv.close()
srv.wait_closed()
request.addfinalizer(tear_down)
return (host, port)
yield (host, port)
loop.run_until_complete(controller.stop())
for module in MODULES:
instance = module.instance()
monkeypatch.setattr('gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.close', lambda self: True)
loop.run_until_complete(instance.unload())
srv.close()
srv.wait_closed()
@pytest.fixture