mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #32416 -- Added LiveServerThread.server_class to ease subclassing.
This commit is contained in:
committed by
Mariusz Felisiak
parent
0963f184ab
commit
91c243f80f
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user