Your question
I was unittesting my application. I wrote three tests. When I run the tests the first one works fine but in the second and third the get_received function returns an empty list.
Here is my code:
class MainTest(unittest.TestCase):
def setUp(self):
self.app = create_app(DevelopmentConfig())
def test_connect(self):
client = socketio.test_client(self.app)
assert not client.is_connected()
client = socketio.test_client(self.app, query_string='?api_key=random')
assert client.is_connected()
print(client.get_received())
client.disconnect()
def test_mapHashID(self):
client = socketio.test_client(self.app, query_string='?api_key=random')
assert client.is_connected()
print(client.get_received())
hashID = uuid.uuid1()
client.emit('mapHashID', hashID.hex)
client.disconnect()
def test_onlineUsers(self):
client = socketio.test_client(self.app, query_string='?api_key=random')
assert client.is_connected()
print(client.get_received())
client.emit('onlineUsers')
print(client.get_received())
client.disconnect()
if __name__ == '__main__':
unittest.main()
Logs
These are the logs.
Connected: h8AdDg_5SZ1y0pDdAAAB
[{'name': 'authorize', 'args': [1], 'namespace': '/'}]
Disconnected: h8AdDg_5SZ1y0pDdAAAB
.[]
.[]
[]
.
----------------------------------------------------------------------
Ran 3 tests in 0.092s
OK
Your question
I was unittesting my application. I wrote three tests. When I run the tests the first one works fine but in the second and third the get_received function returns an empty list.
Here is my code:
Logs
These are the logs.