summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2013-09-22 15:55:09 +0200
committerFlorian Apolloner <florian@apolloner.eu>2013-09-22 22:08:59 +0200
commit18fe77e4ed01a7761a24de7ec7b1c3a1314fc197 (patch)
treebc1ee81404e1b25f1f747f526abe2bb7423b0469 /tests
parentb5eddde09523bd55cde1cf8e22d46d3f594503d7 (diff)
[1.5.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
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/servers/tests.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/regressiontests/servers/tests.py b/tests/regressiontests/servers/tests.py
index 4495596dfa..8bf13127ee 100644
--- a/tests/regressiontests/servers/tests.py
+++ b/tests/regressiontests/servers/tests.py
@@ -5,6 +5,7 @@ Tests for django.core.servers.
from __future__ import unicode_literals
import os
+import socket
try:
from urllib.request import urlopen, HTTPError
except ImportError: # Python 2
@@ -12,7 +13,6 @@ except ImportError: # Python 2
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._os import upath
@@ -66,7 +66,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)