Define port for LiveServerTestCase in 1.11?

31 views
Skip to first unread message

Simon McConnell

unread,
May 7, 2017, 12:18:06 AM5/7/17
to Django users

Hi,

 

Is it possible to define the port for LiveServerTestCase in Django 1.11?  Google requires a static address for OAuth authentication.

 

 

from docs:

 

Changed in Django 1.11:

In older versions, Django tried a predefined port range which could be customized in various ways including the DJANGO_LIVE_TEST_SERVER_ADDRESS environment variable. This is removed in favor of the simpler “bind to port 0” technique.

Tim Graham

unread,
May 7, 2017, 6:17:32 AM5/7/17
to Django users
No. This is discussed in more detail on django-developers: https://groups.google.com/d/topic/django-developers/J2nPccK9kT8/discussion

Simon McConnell

unread,
May 7, 2017, 3:59:53 PM5/7/17
to Django users
Thanks.  I got it working by adding

from django.test.testcases import LiveServerThread

class FixedPortServerThread(LiveServerThread):
def _create_server(self, port):
return super(FixedPortServerThread, self)._create_server(port=8001)

class MyStaticLiveServerTestCase(StaticLiveServerTestCase):
server_thread_class = FixedPortServerThread

class TestGoogleLogin(MyStaticLiveServerTestCase):
...
Reply all
Reply to author
Forward
0 new messages