Skip to content
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

fix: use a non threaded server in SeleniumTestCase #1325

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion game/end_to_end_tests/selenium_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,26 @@
see more information here: https://github.com/jazzband/django-pipeline/issues/593
"""

from django.contrib.staticfiles.testing import LiveServerTestCase
from django.core.servers.basehttp import WSGIServer
from django.test.testcases import (
LiveServerTestCase,
LiveServerThread,
QuietWSGIRequestHandler,
)
from django_selenium_clean import SeleniumTestCase


class NonThreadedLiveServerThread(LiveServerThread):
"""
Replaces ThreadedWSGIServer with WSGIServer as the threaded one doesn't close the DB connections properly, thus
triggering random "DB table locked" errors.
"""

def _create_server(self):
return WSGIServer(
(self.host, self.port), QuietWSGIRequestHandler, allow_reuse_address=False
)


SeleniumTestCase.__bases__ = (LiveServerTestCase,)
SeleniumTestCase.server_thread_class = NonThreadedLiveServerThread
2 changes: 1 addition & 1 deletion rapid_router_test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

SELENIUM_WEBDRIVERS = {
"default": {"callable": webdriver.Chrome, "args": (), "kwargs": {}},
"chrome": {"callable": webdriver.Firefox, "args": (), "kwargs": {}},
"firefox": {"callable": webdriver.Firefox, "args": (), "kwargs": {}},
"chrome-headless": {
"callable": webdriver.Chrome,
"args": (),
Expand Down