mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user