From 7e352213d9ac795a954bd13065c8986f5aee4a71 Mon Sep 17 00:00:00 2001 From: Christofer Bertonha Date: Thu, 27 Oct 2022 15:59:37 -0300 Subject: [PATCH 1/2] feat: fail on use ChannelsLiveServerTestCase when daphne is not installed --- channels/testing/live.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/channels/testing/live.py b/channels/testing/live.py index ce5ff109..d841723c 100644 --- a/channels/testing/live.py +++ b/channels/testing/live.py @@ -1,6 +1,10 @@ from functools import partial -from daphne.testing import DaphneProcess +try: + from daphne.testing import DaphneProcess +except ImportError: + DaphneProcess = None + from django.contrib.staticfiles.handlers import ASGIStaticFilesHandler from django.core.exceptions import ImproperlyConfigured from django.db import connections @@ -40,6 +44,9 @@ def live_server_ws_url(self): return "ws://%s:%s" % (self.host, self._port) def _pre_setup(self): + if self.ProtocolServerProcess is None: + raise ImproperlyConfigured("Daphne is not installed") + for connection in connections.all(): if self._is_in_memory_db(connection): raise ImproperlyConfigured( From 23f0e41a32133d1b50c69137bb21be7ab6d3c619 Mon Sep 17 00:00:00 2001 From: Christofer Bertonha Date: Fri, 28 Oct 2022 14:04:01 -0300 Subject: [PATCH 2/2] remove daphne from tests env --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ac6399cb..a2cab6eb 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ envlist = [testenv] usedevelop = true -extras = tests, daphne +extras = tests commands = pytest -v {posargs} deps =