summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2015-02-05 23:02:10 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2015-09-09 23:01:16 +0200
commit326bc0955b2e9ab6b6cfd62263c9b3fe2fb1d333 (patch)
tree587ced3a87dae781adf6e38924aaf3c59d36f720
parente39dd618085bd437bcd800b5a0a7e29751ab6274 (diff)
Allowed a port range for the liveserver by default.
This is required for running tests in parallel.
-rw-r--r--django/core/management/commands/test.py2
-rw-r--r--django/test/testcases.py2
-rw-r--r--docs/ref/django-admin.txt6
-rw-r--r--docs/releases/1.9.txt3
-rw-r--r--docs/topics/testing/tools.txt17
-rwxr-xr-xtests/runtests.py2
6 files changed, 23 insertions, 9 deletions
diff --git a/django/core/management/commands/test.py b/django/core/management/commands/test.py
index 0d084e1e91..ad54994d74 100644
--- a/django/core/management/commands/test.py
+++ b/django/core/management/commands/test.py
@@ -47,7 +47,7 @@ class Command(BaseCommand):
action='store', dest='liveserver', default=None,
help='Overrides the default address where the live server (used '
'with LiveServerTestCase) is expected to run from. The '
- 'default value is localhost:8081.'),
+ 'default value is localhost:8081-8179.'),
test_runner_class = get_runner(settings, self.test_runner)
if hasattr(test_runner_class, 'option_list'):
diff --git a/django/test/testcases.py b/django/test/testcases.py
index 0c704ad951..fd93ba5bad 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -1318,7 +1318,7 @@ class LiveServerTestCase(TransactionTestCase):
# Launch the live server's thread
specified_address = os.environ.get(
- 'DJANGO_LIVE_TEST_SERVER_ADDRESS', 'localhost:8081')
+ 'DJANGO_LIVE_TEST_SERVER_ADDRESS', 'localhost:8081-8179')
# The specified ports may be of the form '8000-8010,8080,9200-9300'
# i.e. a comma-separated list of ports or ranges of ports, so we break
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index 3dd4cf3a6d..a98b60b45f 100644
--- a/docs/ref/django-admin.txt
+++ b/docs/ref/django-admin.txt
@@ -1227,7 +1227,11 @@ provided by the :setting:`TEST_RUNNER` setting.
The ``--liveserver`` option can be used to override the default address where
the live server (used with :class:`~django.test.LiveServerTestCase`) is
-expected to run from. The default value is ``localhost:8081``.
+expected to run from. The default value is ``localhost:8081-8179``.
+
+.. versionchanged:: 1.9
+
+ In earlier versions, the default value was ``localhost:8081``.
.. django-admin-option:: --keepdb
diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt
index f1d59fce16..99b6e44bc3 100644
--- a/docs/releases/1.9.txt
+++ b/docs/releases/1.9.txt
@@ -1055,6 +1055,9 @@ Miscellaneous
changed. They used to be ``(old_names, mirrors)`` tuples. Now they're just
the first item, ``old_names``.
+* By default :class:`~django.test.LiveServerTestCase` attempts to find an
+ available port in the 8081-8179 range instead of just trying port 8081.
+
.. _deprecated-features-1.9:
Features deprecated in 1.9
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index 28a4921198..52a00b7ded 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -812,11 +812,18 @@ This allows the use of automated test clients other than the
client, to execute a series of functional tests inside a browser and simulate a
real user's actions.
-By default the live server's address is ``'localhost:8081'`` and the full URL
-can be accessed during the tests with ``self.live_server_url``. If you'd like
-to change the default address (in the case, for example, where the 8081 port is
-already taken) then you may pass a different one to the :djadmin:`test` command
-via the :djadminopt:`--liveserver` option, for example:
+By default the live server listens on ``localhost`` and picks the first
+available port in the ``8081-8179`` range. Its full URL can be accessed with
+``self.live_server_url`` during the tests.
+
+.. versionchanged:: 1.9
+
+ In earlier versions, the live server's default address was always
+ ``'localhost:8081'``.
+
+If you'd like to select another address then you may pass a different one to
+the :djadmin:`test` command via the :djadminopt:`--liveserver` option, for
+example:
.. code-block:: console
diff --git a/tests/runtests.py b/tests/runtests.py
index 58181a0e92..0577737a5f 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -388,7 +388,7 @@ if __name__ == "__main__":
parser.add_argument('--liveserver',
help='Overrides the default address where the live server (used with '
'LiveServerTestCase) is expected to run from. The default value '
- 'is localhost:8081.')
+ 'is localhost:8081-8179.')
parser.add_argument(
'--selenium', action='store_true', dest='selenium', default=False,
help='Run the Selenium tests as well (if Selenium is installed).')