From 56201fe5a85ead96f00d8ad2eda5cfd2bc4cb4b0 Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Sun, 22 Sep 2013 15:55:09 +0200 Subject: [1.6.x] Fixed "Address already in use" from liveserver. Our WSGIServer rewrapped the socket errors from server_bind into WSGIServerExceptions, which is used later on to provide nicer error messages in runserver and used by the liveserver to see if the port is already in use. But wrapping server_bind isn't enough since it only binds to the socket, socket.listen (which is called from server_activate) could also raise "Address already in use". Instead of overriding server_activate too I chose to just catch socket errors, which seems to make more sense anyways and should be more robust against changes in wsgiref. Backport of 2ca00faa913754cd5860f6e1f23c8da2529c691a from master. --- tests/servers/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/servers') diff --git a/tests/servers/tests.py b/tests/servers/tests.py index caa2ddb084..d4025c435b 100644 --- a/tests/servers/tests.py +++ b/tests/servers/tests.py @@ -5,10 +5,10 @@ Tests for django.core.servers. from __future__ import unicode_literals import os +import socket from django.core.exceptions import ImproperlyConfigured from django.test import LiveServerTestCase -from django.core.servers.basehttp import WSGIServerException from django.test.utils import override_settings from django.utils.http import urlencode from django.utils.six.moves.urllib.error import HTTPError @@ -71,7 +71,7 @@ class LiveServerAddress(LiveServerBase): cls.raises_exception('localhost', ImproperlyConfigured) # The host must be valid - cls.raises_exception('blahblahblah:8081', WSGIServerException) + cls.raises_exception('blahblahblah:8081', socket.error) # The list of ports must be in a valid format cls.raises_exception('localhost:8081,', ImproperlyConfigured) -- cgit v1.3