Add pytest.ini and fix tests

This commit is contained in:
Lawrence Akka 2022-12-01 11:41:11 +00:00
parent 879e43789d
commit 81a11dfa43
2 changed files with 4 additions and 6 deletions

2
pytest.ini Normal file
View File

@ -0,0 +1,2 @@
[pytest]
asyncio_mode = auto

View File

@ -44,14 +44,13 @@ class FakeServer:
@pytest.fixture()
async def fakeserver(event_loop, unused_tcp_port):
async def fakeserver(event_loop):
"""Create a fakeserver pytest fixture."""
server = FakeServer(event_loop, unused_tcp_port)
server = FakeServer(event_loop, 4242)
yield server
await server.close()
@pytest.mark.asyncio
async def test_send_valid(fakeserver):
def handler(input):
return '{"message": "ok"}'
@ -69,7 +68,6 @@ async def test_send_valid(fakeserver):
assert await hub._send('test', {'message': 'not ok'}) is False
@pytest.mark.asyncio
async def test_send_invalid_json(fakeserver):
def handler(input):
return '{"message": not valid json"}'
@ -86,7 +84,6 @@ async def test_send_invalid_json(fakeserver):
await hub._send('test')
@pytest.mark.asyncio
async def test_send_timeout(fakeserver):
def handler(input):
time.sleep(0.2)
@ -99,7 +96,6 @@ async def test_send_timeout(fakeserver):
await hub._send('test')
@pytest.mark.asyncio
async def test_send_retries(fakeserver):
def handler(input):
return '{"message": "error"}'