Combine test_subscription.py to test_pubsub.py

And add a bunch of tests for pubsub
This commit is contained in:
mhchia
2019-07-28 18:07:48 +08:00
parent 96563c0d84
commit 550289a439
5 changed files with 125 additions and 20 deletions

View File

@ -27,21 +27,25 @@ def num_hosts():
@pytest.fixture
async def hosts(num_hosts):
new_node_coros = tuple(
_hosts = await asyncio.gather(*[
new_node(transport_opt=[str(LISTEN_MADDR)])
for _ in range(num_hosts)
)
_hosts = await asyncio.gather(*new_node_coros)
])
await asyncio.gather(*[
_host.get_network().listen(LISTEN_MADDR)
for _host in _hosts
])
yield _hosts
# Clean up
listeners = []
for _host in _hosts:
for listener in _host.get_network().listeners.values():
listener.server.close()
await listener.server.wait_closed()
listeners.append(listener)
await asyncio.gather(*[
listener.server.wait_closed()
for listener in listeners
])
@pytest.fixture