diff options
| author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2021-02-11 18:32:09 -0800 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-02-12 08:17:46 +0100 |
| commit | 91c243f80f36b6aa4ae20461b6914b63db81df17 (patch) | |
| tree | a8b552afe3bc6a671405a720c3b898758c2a2008 /tests/servers/test_liveserverthread.py | |
| parent | 0963f184abd96800b76b19a6a181e1b544c7fafe (diff) | |
Refs #32416 -- Added LiveServerThread.server_class to ease subclassing.
Diffstat (limited to 'tests/servers/test_liveserverthread.py')
| -rw-r--r-- | tests/servers/test_liveserverthread.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/servers/test_liveserverthread.py b/tests/servers/test_liveserverthread.py index a2af459edc..8dc213137a 100644 --- a/tests/servers/test_liveserverthread.py +++ b/tests/servers/test_liveserverthread.py @@ -1,5 +1,6 @@ from django.db import DEFAULT_DB_ALIAS, connections from django.test import LiveServerTestCase, TestCase +from django.test.testcases import LiveServerThread class LiveServerThreadTest(TestCase): @@ -23,3 +24,18 @@ class LiveServerThreadTest(TestCase): self.assertFalse(conn.is_usable()) finally: conn.dec_thread_sharing() + + def test_server_class(self): + class FakeServer: + def __init__(*args, **kwargs): + pass + + class MyServerThread(LiveServerThread): + server_class = FakeServer + + class MyServerTestCase(LiveServerTestCase): + server_thread_class = MyServerThread + + thread = MyServerTestCase._create_server_thread(None) + server = thread._create_server() + self.assertIs(type(server), FakeServer) |
