summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-06-23 12:04:05 -0400
committerGitHub <noreply@github.com>2016-06-23 12:04:05 -0400
commit81cdcb66bc74a0768d13f0e18872d46739028e64 (patch)
treea7b0c5577f17242f992ebc308acfccc738635d0a /docs
parentb5a1c3a6f50362b57603e1833e44bff5628dde3c (diff)
Fixed #26791 -- Replaced LiveServerTestCase port ranges with binding to port 0.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/django-admin.txt6
-rw-r--r--docs/releases/1.11.txt9
-rw-r--r--docs/topics/testing/tools.txt37
3 files changed, 16 insertions, 36 deletions
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index a783767981..3a0b05516e 100644
--- a/docs/ref/django-admin.txt
+++ b/docs/ref/django-admin.txt
@@ -1227,12 +1227,6 @@ Stops running tests and reports the failure immediately after a test fails.
Controls the test runner class that is used to execute tests. This value
overrides the value provided by the :setting:`TEST_RUNNER` setting.
-.. django-admin-option:: --liveserver LIVESERVER
-
-Overrides the default address where the live server (used with
-:class:`~django.test.LiveServerTestCase`) is expected to run from. The default
-value is ``localhost:8081-8179``.
-
.. django-admin-option:: --noinput, --no-input
Suppresses all user prompts. A typical prompt is a warning about deleting an
diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt
index 9106614d9c..dc8b657a13 100644
--- a/docs/releases/1.11.txt
+++ b/docs/releases/1.11.txt
@@ -250,6 +250,15 @@ Django 1.11 sets PostgreSQL 9.3 as the minimum version it officially supports.
Support for PostGIS 2.0 is also removed as PostgreSQL 9.2 is the last version
to support it.
+``LiveServerTestCase`` binds to port zero
+-----------------------------------------
+
+Rather than taking a port range and iterating to find a free port,
+``LiveServerTestCase`` binds to port zero and relies on the operating system
+to assign a free port. The ``DJANGO_LIVE_TEST_SERVER_ADDRESS`` environment
+variable is no longer used, and as it's also no longer used, the
+``manage.py test --liveserver`` option is removed.
+
Miscellaneous
-------------
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index aa0c412531..1473f06f6a 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -814,39 +814,16 @@ 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 listens on ``localhost`` and picks the first
-available port in the ``8081-8179`` range. Its full URL can be accessed with
+The live server listens on ``localhost`` and binds to port 0 which uses a free
+port assigned by the operating system. The server's URL can be accessed with
``self.live_server_url`` during the tests.
-If you'd like to select another address, you may pass a different one using the
-:option:`test --liveserver` option, for example:
+.. versionchanged:: 1.11
-.. code-block:: console
-
- $ ./manage.py test --liveserver=localhost:8082
-
-Another way of changing the default server address is by setting the
-`DJANGO_LIVE_TEST_SERVER_ADDRESS` environment variable somewhere in your
-code (for example, in a :ref:`custom test runner<topics-testing-test_runner>`)::
-
- import os
- os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = 'localhost:8082'
-
-In the case where the tests are run by multiple processes in parallel (for
-example, in the context of several simultaneous `continuous integration`_
-builds), the processes will compete for the same address, and therefore your
-tests might randomly fail with an "Address already in use" error. To avoid this
-problem, you can pass a comma-separated list of ports or ranges of ports (at
-least as many as the number of potential parallel processes). For example:
-
-.. code-block:: console
-
- $ ./manage.py test --liveserver=localhost:8082,8090-8100,9000-9200,7041
-
-Then, during test execution, each new live test server will try every specified
-port until it finds one that is free and takes it.
-
-.. _continuous integration: https://en.wikipedia.org/wiki/Continuous_integration
+ 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.
To demonstrate how to use ``LiveServerTestCase``, let's write a simple Selenium
test. First of all, you need to install the `selenium package`_ into your