Figure 7-2. Our site starts to look a little better…
Switching to StaticLiveServerCase
If you run the FT though, it won’t pass:
AssertionError: 110.0 != 512 within 5 delta
That’s because, although
runserver
automagically finds static files,
LiveServerTest
Case
doesn’t. Never fear though, the Django developers have made a more magical test
class called
StaticLiveServerCase
(see
the docs).
Let’s switch to that:
functional_tests/tests.py.
@@ -1,8 +1,8 @@
-from django.test import LiveServerTestCase
+from django.contrib.staticfiles.testing import StaticLiveServerCase
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
-class NewVisitorTest(LiveServerTestCase):
+class NewVisitorTest(StaticLiveServerCase):
And now it will now find the new CSS, which will get our test to pass:
$
python3 manage.py test functional_tests
Creating test database for alias 'default'...
..
---------------------------------------------------------------------
Ran 2 tests in 9.764s
124
|
Chapter 7: Prettification: Layout and Styling, and What to Test About It