-
-
Notifications
You must be signed in to change notification settings - Fork 890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test client doesn't encode/decode the data #1427
Closed
Comments
what about just calling pkt.decode(pkt.encode()) in test_client.py?
|
This was referenced Dec 9, 2020
Closed
well that didn't work :( |
I have no idea if i should submit a PR for this or not. I haven't ever contributed to a project before. so anyway, i think this works. It forces the encoding for non binary events and fixes the two issue that i noted above... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sending data with emit() and getting the data back with get_received() returns the actual object emitted not one that got encoded to json and back. This can mask at least 2 different types of bugs.
The real socketio client encodes the data in packet.py encode()
but the socketio test client just stores the object for later retrieval.
This caused my test code to miss two errors:
Steps to reproduce the behavior:
Case 1:
Case 2:
#in server
data = {'test': 1}
emit('test', data)
data['test']=2
#in pytest
assert socketio_client.get_received()[0]['args'][0]['test'] == 1 #this assert will fail
Expected behavior
In the first case should throw an exception
in the second case the assertion should pass
The text was updated successfully, but these errors were encountered: