channels icon indicating copy to clipboard operation
channels copied to clipboard

ChannelsLiveServerTestCase failing to load Apps

Open TNWorld opened this issue 6 years ago • 19 comments

I can not complete the four part Channels tutorial. I can run the server and it works as expected, however the ChannelsLiveServerTestCase does not work. I have also tried using the standard LiveServerTestCase and it can run tests, however does not have the channels functionality as expected.

What I expected to happen vs. what actually happened This test from the django channels tutorial part four should pass: python manage.py test chat.tests

from channels.testing import ChannelsLiveServerTestCase
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.wait import WebDriverWait

class ChatTests(ChannelsLiveServerTestCase):
    serve_static = True  # emulate StaticLiveServerTestCase

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        try:
            # NOTE: Requires "chromedriver" binary to be installed in $PATH
            cls.driver = webdriver.Chrome()
        except:
            super().tearDownClass()
            raise

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()
        super().tearDownClass()

    def test_when_chat_message_posted_then_seen_by_everyone_in_same_room(self):
        try:
            self._enter_chat_room('room_1')

            self._open_new_window()
            self._enter_chat_room('room_1')

            self._switch_to_window(0)
            self._post_message('hello')
            WebDriverWait(self.driver, 2).until(lambda _:
                'hello' in self._chat_log_value,
                'Message was not received by window 1 from window 1')
            self._switch_to_window(1)
            WebDriverWait(self.driver, 2).until(lambda _:
                'hello' in self._chat_log_value,
                'Message was not received by window 2 from window 1')
        finally:
            self._close_all_new_windows()

    def test_when_chat_message_posted_then_not_seen_by_anyone_in_different_room(self):
        try:
            self._enter_chat_room('room_1')

            self._open_new_window()
            self._enter_chat_room('room_2')

            self._switch_to_window(0)
            self._post_message('hello')
            WebDriverWait(self.driver, 2).until(lambda _:
                'hello' in self._chat_log_value,
                'Message was not received by window 1 from window 1')

            self._switch_to_window(1)
            self._post_message('world')
            WebDriverWait(self.driver, 2).until(lambda _:
                'world' in self._chat_log_value,
                'Message was not received by window 2 from window 2')
            self.assertTrue('hello' not in self._chat_log_value,
                'Message was improperly received by window 2 from window 1')
        finally:
            self._close_all_new_windows()

    # === Utility ===

    def _enter_chat_room(self, room_name):
        self.driver.get(self.live_server_url + '/chat/')
        ActionChains(self.driver).send_keys(room_name + '\n').perform()
        WebDriverWait(self.driver, 2).until(lambda _:
            room_name in self.driver.current_url)

    def _open_new_window(self):
        self.driver.execute_script('window.open("about:blank", "_blank");')
        self.driver.switch_to_window(self.driver.window_handles[-1])

    def _close_all_new_windows(self):
        while len(self.driver.window_handles) > 1:
            self.driver.switch_to_window(self.driver.window_handles[-1])
            self.driver.execute_script('window.close();')
        if len(self.driver.window_handles) == 1:
            self.driver.switch_to_window(self.driver.window_handles[0])

    def _switch_to_window(self, window_index):
        self.driver.switch_to_window(self.driver.window_handles[window_index])

    def _post_message(self, message):
        ActionChains(self.driver).send_keys(message + '\n').perform()

    @property
    def _chat_log_value(self):
        return self.driver.find_element_by_css_selector('#chat-log').get_property('value')

However it is failing and giving the following trace

Creating test database for alias 'default'...
Destroying old test database for alias 'default'...
System check identified no issues (0 silenced).

DevTools listening on ws://127.0.0.1:55140/devtools/browser/6a3609e3-e493-47bc-85da-4259aac7b6da
ETraceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
ETraceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input

======================================================================
ERROR: test_when_chat_message_posted_then_not_seen_by_anyone_in_different_room (chat.tests.ChatTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\django\test\testcases.py", line 202, in __call__
    self._pre_setup()
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
    self._server_process.start()
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\process.py", line 112, in start
    self._popen = self._Popen(self)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'DaphneProcess.__init__.<locals>.<lambda>'

======================================================================
ERROR: test_when_chat_message_posted_then_seen_by_everyone_in_same_room (chat.tests.ChatTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\django\test\testcases.py", line 202, in __call__
    self._pre_setup()
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
    self._server_process.start()
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\process.py", line 112, in start
    self._popen = self._Popen(self)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'DaphneProcess.__init__.<locals>.<lambda>'

----------------------------------------------------------------------
Ran 0 tests in 4.791s

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

OS, runtime environment and browser Windows 10 Django 1.11 and 2.0 chromewebdriver

What I have tried I have tried following this solution for a similar problem Which replaces import pickle with import dill as pickle in multiprocessing\reduction.py https://stackoverflow.com/questions/50016048/django-channels-2-with-selenium-test-failed

However I then get the following error

Creating test database for alias 'default'... Destroying old test database for alias 'default'... System check identified no issues (0 silenced).

DevTools listening on ws://127.0.0.1:55187/devtools/browser/28e3d4b6-a30c-44e9-a27f-d7e387471bd4
C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\daphne\server.py:13: UserWarning: Something has already installed a non-asyncio Twisted reactor. Attempting to uninstall it; you can fix this warning by importing daphne.server early in your codebase or finding the package that imports Twisted and importing it later on.
  UserWarning,
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\dill\_dill.py", line 304, in load
    obj = pik.load()
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\dill\_dill.py", line 465, in find_class
    return StockUnpickler.find_class(self, module, name)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\channels\auth.py", line 12, in <module>
    from django.contrib.auth.models import AnonymousUser
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
    class AbstractBaseUser(models.Model):
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\django\db\models\base.py", line 87, in __new__
    app_config = apps.get_containing_app_config(module)
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\django\apps\registry.py", line 249, in get_containing_app_config
    self.check_apps_ready()
  File "C:\Users\SubAtomicManiac\Anaconda5\envs\SoftEng\lib\site-packages\django\apps\registry.py", line 132, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

I am completely new to channels and testing, and I couldn't find a solution anywhere. I have tried with different versions of python/django/channels and I would get varying errors but none would work. Ideally I would like to get this to work with python 3.7, django 2.0+ and channels 2.0+ Thanks in advance

TNWorld avatar Dec 29 '18 17:12 TNWorld

Unfortunately I don't think this is a bug in Channels, and so we can't help you on here - you're better off going to one of the mailing lists/stackoverflow or similar: https://channels.readthedocs.io/en/latest/support.html

Nothing I can see in your traceback really tells what's wrong, though, maybe you have some packages mis-installed or something (the multiprocessing error is very strange indeed).

andrewgodwin avatar Dec 30 '18 17:12 andrewgodwin

@andrewgodwin I want to reopen this issue, I don't believe this is an application specific problem.

I have created a an example Django + Channels project with a Poetry lock file for the dependency tree where we can easily see this error. It is run using Python 3.8.1, Django 3.0.3, and Channels 2.4.0 The instructions for running it are located in the README.rst

test-channels.tar.gz

djstein avatar Feb 19 '20 22:02 djstein

Hi @djstein. Thanks for the project. I will reopen to take a look.

carltongibson avatar Feb 20 '20 08:02 carltongibson

Just followed the chat tutorial on macOS 10.15.5 and got same error. Here's my output from pip freeze:

asgiref==3.2.10
astroid==2.4.2
async-timeout==3.0.1
attrs==19.3.0
autobahn==20.6.1
Automat==20.2.0
autopep8==1.5.3
cffi==1.14.0
channels==2.4.0
channels-redis==2.4.2
constantly==15.1.0
cryptography==2.9.2
daphne==2.5.0
Django==3.0.7
hiredis==1.0.1
hyperlink==19.0.0
idna==2.9
incremental==17.5.0
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
msgpack==0.6.2
pep8==1.7.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.6.0
pycparser==2.20
PyHamcrest==2.0.2
pylint==2.5.3
pyOpenSSL==19.1.0
pytz==2020.1
selenium==3.141.0
service-identity==18.1.0
six==1.15.0
sqlparse==0.3.1
toml==0.10.1
Twisted==20.3.0
txaio==20.4.1
urllib3==1.25.9
wrapt==1.12.1
zope.interface==5.1.0

cglusky avatar Jun 22 '20 14:06 cglusky

I'm fighting with this error too (channels 3.0.1, django 3.1, py 3.9.1, macOS). I don't have a solution, just observations: it looks like Daphne uses lambdas and reduction.py in the standard library multiprocessing tries to pickle them, but lambdas and nested functions can't be pickled by the standard library's pickler. They could be pickled by dill, but putting dill into reduction.py causes a circular import (dill imports from reduction.py). Anyway, my best guess so far is that replacing any lambdas or nested functions in Daphne with top level functions that can be pickled might solve it, though that looks to be a substantial project.

eyesee1 avatar Jan 25 '21 02:01 eyesee1

I'm following the tutorial of channels (channels 3.03, Django 3.2.4, Python 3.8.7, macOS) and encountering the same issue. I, too, arrived to a similar error. Seems like the output from channels/testing/live.py cannot be properly handled.

Here's my error message:

======================================================================
ERROR: test_when_chat_message_posted_then_seen_by_everyone_in_same_room (chat.tests.ChatTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/site-packages/django/test/testcases.py", line 272, in _setup_and_call
    self._pre_setup()
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/site-packages/channels/testing/live.py", line 52, in _pre_setup
    self._server_process.start()
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 47, in _launch
    reduction.dump(process_obj, fp)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'convert_exception_to_response.<locals>.inner'

----------------------------------------------------------------------

boonleng avatar Jun 26 '21 16:06 boonleng

@boonleng same error! ERROR: test_when_chat_message_posted_then_seen_by_everyone_in_same_room (chat.tests.ChatTests)

Traceback (most recent call last): File "/Users/crocha/proyectos/django/personal/virtuales/channels/lib/python3.8/site-packages/django/test/testcases.py", line 272, in _setup_and_call self._pre_setup() File "/Users/crocha/proyectos/django/personal/virtuales/channels/lib/python3.8/site-packages/channels/testing/live.py", line 52, in _pre_setup self._server_process.start() File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/multiprocessing/process.py", line 121, in start self._popen = self._Popen(self) File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/multiprocessing/context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/multiprocessing/context.py", line 283, in _Popen return Popen(process_obj) File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in init super().init(process_obj) File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_fork.py", line 19, in init self._launch(process_obj) File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 47, in _launch reduction.dump(process_obj, fp) File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/multiprocessing/reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) AttributeError: Can't pickle local object 'convert_exception_to_response..inner'


Ran 0 tests in 2.536s

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

CARocha avatar Aug 02 '21 01:08 CARocha

I neglected to share this but was able to make the chat example work by downgrading asgiref to 3.3.4.

boonleng avatar Aug 02 '21 12:08 boonleng

@boonleng i working perfect example chat the problem is tests no working same error i never pass test cases.

CARocha avatar Aug 02 '21 15:08 CARocha

Ah you are right. Somehow I confused the testing module with the other issue. I still cannot get the testing module to work too.

boonleng avatar Aug 02 '21 15:08 boonleng

@carltongibson I've confirmed this issue to be specific to Windows environments.

Tested versions

Django == 3.2.4 - 3.2.7
Channels == 3.0.0 - 3.0.4
Asgiref == 3.3.0 - 3.4.1

Related issues

  • idom-team/django-idom#14

Detected in idom-team/django-idom#10 (PR).

Archmonger avatar Sep 10 '21 04:09 Archmonger

Stack Trace

The stack traces in my above comment could be related to a Python standard lib limitation with the pickle library , which is used by multiprocessing. It may be undocumented that this limitation only exists on Windows (?).

I am assuming due to django/django wrapping responses with a locally defined function, the creation of _server_process within ChannelsLiveServerTestCase can't propagate through the multiprocessing module.


Solutions

This second comment on the stackoverflow suggests that pathos.multiprocessing does not have that same limitation due to the use dill.pickle. This package, however, is missing some basic features. We might need monkey patches to get this working, but the patches I've tried haven't worked out.

The multiprocess package may also be something to look at, but I wasn't able to get it to immediately work as a drop-in replacement.


@andrewgodwin Since this is potentially related to django/django, what are your thoughts on this?

Archmonger avatar Sep 11 '21 09:09 Archmonger

Hey @Archmonger — good work on the further investigation.

Can I ask you to stop @mentioning people (Me/Andrew) unless they are directly involved in the conversation — it just creates noise. I see the issue. I see all comments on the repo, but this is not at the top of my list, so short of a contribution it will need to wait. Andrew is no longer maintaining Channels, so it’s really just noise for him. (Andrew is very generous with his time, and happy to advise on specifics, but pulling him into this thread isn’t that.) I hope that makes sense. Thanks.

carltongibson avatar Sep 11 '21 09:09 carltongibson

Andrew was pinged because this might be related to django/django based on my stack trace. Will need his input on whether an issue also needs to be raised over there.

Also based on previous comments I was under the impression you were investigating this.

I will refrain from pinging in the future.

Archmonger avatar Sep 11 '21 10:09 Archmonger

@Archmonger — Thanks. It's just that @mentioning creates unnecessary noise. 👍

carltongibson avatar Sep 11 '21 10:09 carltongibson

Also based on previous comments I was under the impression you were investigating this.

Not actively, currently.

I will in time swing back to it, as other issues are resolved, and time allows, but ideally a contributor would pick it up.

carltongibson avatar Sep 11 '21 10:09 carltongibson

I'm following the tutorial of channels (channels 3.03, Django 3.2.4, Python 3.8.7, macOS) and encountering the same issue. I, too, arrived to a similar error. Seems like the output from channels/testing/live.py cannot be properly handled.

Here's my error message:

======================================================================
ERROR: test_when_chat_message_posted_then_seen_by_everyone_in_same_room (chat.tests.ChatTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/site-packages/django/test/testcases.py", line 272, in _setup_and_call
    self._pre_setup()
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/site-packages/channels/testing/live.py", line 52, in _pre_setup
    self._server_process.start()
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 47, in _launch
    reduction.dump(process_obj, fp)
  File "/Users/boonleng/.pyenv/versions/3.8.7/lib/python3.8/multiprocessing/reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'convert_exception_to_response.<locals>.inner'

----------------------------------------------------------------------

Hi !! I had the same error like you. please did you found the solutions ? Here is my error log:

`(env) C:\Users\Admin\Documents\django\testpushnotification>py manage.py test chat.tests Creating test database for alias 'default'... Destroying old test database for alias 'default'... System check identified no issues (0 silenced).

DevTools listening on ws://127.0.0.1:59077/devtools/browser/450f9a15-d37d-42d3-9187-05e0ab8f6ace [8416:2100:1230/085033.814:ERROR:chrome_browser_main_extra_parts_metrics.cc(226)] crbug.com/1216328: Checking Bluetooth availability started. Please report if there is no report that this ends. [8416:2100:1230/085033.815:ERROR:chrome_browser_main_extra_parts_metrics.cc(229)] crbug.com/1216328: Checking Bluetooth availability ended. [8416:2100:1230/085033.816:ERROR:chrome_browser_main_extra_parts_metrics.cc(232)] crbug.com/1216328: Checking default browser status started. Please report if there is no report that this ends. [8416:2100:1230/085033.873:ERROR:chrome_browser_main_extra_parts_metrics.cc(236)] crbug.com/1216328: Checking default browser status ended. Traceback (most recent call last): File "", line 1, in File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main exitcode = _main(fd, parent_sentinel) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 126, in _main self = reduction.pickle.load(from_parent) EOFError: Ran out of input EETraceback (most recent call last): File "", line 1, in File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 107, in spawn_main new_handle = reduction.duplicate(pipe_handle, File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 79, in duplicate return _winapi.DuplicateHandle( OSError: [WinError 6] Descripteur non valide

====================================================================== ERROR: test_when_chat_message_posted_then_not_seen_by_anyone_in_different_room (chat.tests.ChatTests)

Traceback (most recent call last): File "C:\Users\Admin\Documents\django\testpushnotification\env\lib\site-packages\django\test\testcases.py", line 272, in _setup_and_call self._pre_setup() File "C:\Users\Admin\Documents\django\testpushnotification\env\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup self._server_process.start() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start self._popen = self._Popen(self) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen return Popen(process_obj) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in init reduction.dump(process_obj, to_child) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) AttributeError: Can't pickle local object 'convert_exception_to_response..inner'

====================================================================== ERROR: test_when_chat_message_posted_then_seen_by_everyone_in_same_room (chat.tests.ChatTests)

Traceback (most recent call last): File "C:\Users\Admin\Documents\django\testpushnotification\env\lib\site-packages\django\test\testcases.py", line 272, in _setup_and_call self._pre_setup() File "C:\Users\Admin\Documents\django\testpushnotification\env\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup self._server_process.start() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start self._popen = self._Popen(self) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen return Popen(process_obj) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in init reduction.dump(process_obj, to_child) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) AttributeError: Can't pickle local object 'convert_exception_to_response..inner'


Ran 0 tests in 13.208s

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

nana237 avatar Dec 30 '21 08:12 nana237

As of July 2022 I am still running into this same issue. No fix as yet.

Do other tests work on windows?

davidmiedz avatar Jul 21 '22 01:07 davidmiedz

I have also the same issue.

nana237 avatar Aug 02 '22 09:08 nana237

I've merged #1906 to enforce fork here, which at least lets test cases work on macOS. (We'll need a fuller solution long-term, and for Windows support.)

Note pre-4.0 this requires the development version of daphne as well. See #1898

carltongibson avatar Aug 21 '22 09:08 carltongibson