Loading docs/topics/testing/tools.txt +13 −4 Original line number Diff line number Diff line Loading @@ -826,12 +826,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. The code for this test may look as follows:: from django.test import LiveServerTestCase 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 Loading Loading
docs/topics/testing/tools.txt +13 −4 Original line number Diff line number Diff line Loading @@ -826,12 +826,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. The code for this test may look as follows:: from django.test import LiveServerTestCase 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 Loading