-
-
Notifications
You must be signed in to change notification settings - Fork 801
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
Daphne still needed to use channels.testing #1942
Comments
Sure, this was noted in the release notes. The test case depends on the Daphne process to run the web server. |
But if we comment the import of Maybe we could fail the use of |
For the moment I'd suggest importing the communicator from the submodule so you're not blocked. |
Hello @carltongibson I really dunno if is possible to import the both way of importing resulting in the exception:
|
Yep, you're right:
We'll have to make that conditional along the lines of your PR. 👍 |
In the meantime you'll need to install Daphne for testing. |
As a workaround, one can mock the import sys
from unittest.mock import MagicMock
sys.modules["channels.testing.live"] = MagicMock() For me this works for using the |
A downside of this issue is that 35 total dependencies:
Making the import conditional as mentioned above would alleviate this issue. |
Yes, it was this concern that led to making Daphne optional in the first place. 👍 |
I was able to confirm that @philippks's workaround works. ❤️ For import sys
from unittest.mock import MagicMock
sys.modules["channels.testing.live"] = MagicMock() |
* #336 use uvicorn instead of daphne for hot-reloading use uvicorn instead of daphne to run asgi backend app so it can be hot-reloaded on dev environment * #149 store conversations and messages - change in database models for conversations, messages, and conversation participants - api endpoints for conversation related information - api endpoint for user's conversation at `/accounts/{accountID}/conversations` - tests for said endpoints * #148 add pytest for websocket testing * #148 instant messaging - setup websocket for messaging system - receiving messages from the server to clients in real-time. * #344 handle exceptions more consistent * #344 remove unnecessary json.dumps * #344 added `daphne` (again) earlier I removed daphne from dependencies as I thought we don't need it anymore for the ASGI server, but apparently we do need it for the Django channels layer when performing test with `channels.testing` Reference: django/channels#1942
on
channels.testing
module it import all Consumers and TestCases, but theChannelsLiveServerTestCase
imports daphne, if you decided to not have daphne testing is completely not usable.https://github.com/django/channels/blob/main/channels/testing/__init__.py#L4
https://github.com/django/channels/blob/main/channels/testing/live.py#L3
The text was updated successfully, but these errors were encountered: