question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StaticLiveServerChannelTestCase

See original GitHub issue
  • Detailed description of the overall behaviour django channels have basic functionality for UnitTests I’m try write UnitTest based on StaticLiveServerTestCase, after I’m finished I found about ws not work there. Then I’m look at tests included inside in channels and find just ChannelTestCaseMixin. I’m write test: class StaticLiveServerChannelTestCase(ChannelTestCaseMixin, StaticLiveServerTestCase): pass and ws not work.
  • Reasoning why it should be in Channels rather than a third-party app Tests is good, StaticLiveServerTestCase is useful if you write functional tests with Selenium or other staff and that is bad if that type of tests not supports websockets.
  • Examples of usage, if possible (it’s easier to discuss concrete code examples) I’m writing simple ToDo list based on django with channels and angular 4. Here is test which not work https://github.com/Akay7/ToDoList/blob/master/backend/functional_tests/tests.py#L37

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
proofit404commented, Apr 20, 2017

It’s already in master. Use ChannelLiveServerTestCase. It supports websockets and serves static by default.

0reactions
alisciecommented, Jun 11, 2021

It’s already in master. Use ChannelLiveServerTestCase. It supports websockets and serves static by default.

I used it but I got AttributeError: Can't pickle local object 'convert_exception_to_response.<locals>.inner'

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


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('./chromedriver')
        except:
            super().tearDownClass()
            raise

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

    def test_connect(self):
        try:
            res = self.driver.get(self.live_server_url + '/alerts/')
            Debugging(res, color='green')
        except:
            Debugging('xxx', color='green')
Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found