summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-10-28 10:04:20 -0400
committerTim Graham <timograham@gmail.com>2015-10-28 13:51:22 -0400
commit411b8da3626de058b0ccf93456c643c1851fa54c (patch)
tree80e553d82b3c8f92f885a63efbc0d7387189cc87 /docs
parent774a893d0bf3433571a94cd27883fab61010440a (diff)
[1.9.x] Made LiveServerTestCase example use StaticLiveServerTestCase.
Backport of 6b5ae92927cb69e8709ab2bb05f6721a7cd37a3c from master
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/testing/tools.txt25
1 files changed, 12 insertions, 13 deletions
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index 107fb6095c..8c502d6c2e 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -884,12 +884,21 @@ Python path:
$ pip install selenium
Then, add a ``LiveServerTestCase``-based test to your app's tests module
-(for example: ``myapp/tests.py``). The code for this test may look as follows::
+(for example: ``myapp/tests.py``). For this example, we'll assume you're using
+the :mod:`~django.contrib.staticfiles` app and want to have static files served
+during the execution of your tests similar to what we get at development time
+with ``DEBUG=True``, i.e. without having to collect them using
+:djadmin:`collectstatic`. We'll use
+the :class:`~django.contrib.staticfiles.testing.StaticLiveServerTestCase`
+subclass which provides that functionality. Replace it with
+``django.test.LiveServerTestCase`` if you don't need that.
- from django.test import LiveServerTestCase
+The code for this test may look as follows::
+
+ from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from selenium.webdriver.firefox.webdriver import WebDriver
- class MySeleniumTests(LiveServerTestCase):
+ class MySeleniumTests(StaticLiveServerTestCase):
fixtures = ['user-data.json']
@classmethod
@@ -927,16 +936,6 @@ out the `full reference`_ for more details.
.. _full reference: http://selenium-python.readthedocs.org/en/latest/api.html
.. _Firefox: http://www.mozilla.com/firefox/
-.. tip::
-
- If you use the :mod:`~django.contrib.staticfiles` app in your project and
- need to perform live testing, then you might want to use the
- :class:`~django.contrib.staticfiles.testing.StaticLiveServerTestCase`
- subclass which transparently serves all the assets during execution of
- its tests in a way very similar to what we get at development time with
- ``DEBUG=True``, i.e. without having to collect them using
- :djadmin:`collectstatic`.
-
.. note::
When using an in-memory SQLite database to run the tests, the same database