channels icon indicating copy to clipboard operation
channels copied to clipboard

ChannelsLiveServerTestCase fails with django 5.2

Open devkral opened this issue 7 months ago • 8 comments
trafficstars

Django 5.2 made TestCase._pre_setup a classmethod but this isn't reflected in ChannelsLifeServerTestCase.

This is leading to a crash when trying to use ChannelsLiveServerTestCase.

devkral avatar Apr 08 '25 07:04 devkral

@devkral Can you make a pr?

carltongibson avatar Apr 08 '25 07:04 carltongibson

Got the same issue here after following the channels tutorial:

(venv) ➜  meet-and-chat git:(main) ✗ python3 manage.py test app.meet_n_chat.tests
Found 2 test(s).
Creating test database for alias 'default'...
Destroying old test database for alias 'default'...
System check identified no issues (0 silenced).
E
======================================================================
ERROR: setUpClass (app.meet_n_chat.tests.ChatTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/alex/Projects/meet-and-chat/app/meet_n_chat/tests.py", line 14, in setUpClass
    super().setUpClass()
  File "/home/alex/Projects/meet-and-chat/venv/lib/python3.12/site-packages/django/test/testcases.py", line 1119, in setUpClass
    cls._pre_setup()
TypeError: ChannelsLiveServerTestCase._pre_setup() missing 1 required positional argument: 'self'

----------------------------------------------------------------------
Ran 0 tests in 0.001s

FAILED (errors=1)
Destroying test database for alias 'default'...

AlexShonia avatar May 08 '25 09:05 AlexShonia

Yep, https://github.com/django/django/commit/8eca3e9bce519c21340312ee7846c92b27abea79 changed the behaviour here.

carltongibson avatar May 08 '25 10:05 carltongibson

sry not much time, currently quite busy

devkral avatar May 09 '25 07:05 devkral

@carltongibson I think we would need a Django project to test ChannelsLiveServerTestCase. I don't see existing tests for this class right now.

pandafy avatar May 09 '25 10:05 pandafy

@pandafy Yes, we could add a small test project to the test suite.

carltongibson avatar May 09 '25 10:05 carltongibson

Hi @carltongibson, I'm currently working on a fix for this. I’ll keep you posted once it's ready.

dee077 avatar May 20 '25 07:05 dee077

Thanks @dee077 for starting https://github.com/django/channels/pull/2160. We need a solution for this issue in @openwisp and we're happy to help. We're open to suggestions. A big thanks in advance to the maintainers who'll help us out.

nemesifier avatar May 22 '25 18:05 nemesifier

Thank you @dee077 for your work on PR #2160! This issue is currently preventing us (@goauthentik) from upgrading to Django 5.2. If there’s anything I can do to assist in resolving this, please let me know!

melizeche avatar Jul 03 '25 20:07 melizeche