Skip to content
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

More informative assert errors for WebsocketCommunicator. #2098

Merged
merged 3 commits into from
May 13, 2024

Conversation

hovi
Copy link
Contributor

@hovi hovi commented May 12, 2024

Already happened to me twice, that this AssertionError got me puzzled for a bit (being channels newbie and coming back after months), until I figured out, what was going on (socket closed unexpectedly while I wanted to read from it).

Having this kind of informative message would give me immediate hint and make my debugging much faster.

assert response["type"] == "websocket.send"
assert (
response["type"] == "websocket.send"
), f"Expected type 'websocket.send', but was '{response['type']}'"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the useful and important one, the rest I added only for sake of completion.

Copy link
Member

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @hovi — this looks reasonable, yes. Thanks!

Just one comment…

tests/test_testing.py Outdated Show resolved Hide resolved
Co-authored-by: Carlton Gibson <[email protected]>
@carltongibson
Copy link
Member

If you can fix the lint error, we're good to go.

@hovi
Copy link
Contributor Author

hovi commented May 12, 2024

If you can fix the lint error, we're good to go.

I believe I just did. Are you squashing or should I cleanup commits?

@carltongibson carltongibson merged commit 42deaca into django:main May 13, 2024
6 checks passed
@carltongibson
Copy link
Member

Thanks @hovi 🎁

@hovi
Copy link
Contributor Author

hovi commented May 13, 2024

My pleasure, thanks for quick review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants