Django's test runner overrides your settings to force DEBUG to be True, 
which I understand the intention behind, but it is occasionally annoying.  
One solution for those cases is to use `override_settings`, but that has 
very weird effects when using `LiveServerTestCase`.

Minimal repro:

    django-admin.py startproject myproj
    cd myproj
    vi tests.py

In tests.py:

from django.test import LiveServerTestCase
from selenium import webdriver
from django.test.utils import override_settings

@override_settings(DEBUG=True)
class MinimalTest(LiveServerTestCase):

    def setUp(self):
        self.browser = webdriver.Firefox()
        self.browser.implicitly_wait(3)

    def tearDown(self):
        self.browser.quit()


    def test_admin_site_is_there(self):
        self.browser.get(self.live_server_url + '/admin')
        self.assertIn('Django administration', 
self.browser.find_element_by_tag_name('body').text)

Change DEBUG=True to DEBUG=False and this passes.  But, as-is, you get:

  File "/tmp/myproj/test1.py", line 18, in test_admin_site_is_there
    self.assertIn('Django administration', 
self.browser.find_element_by_tag_name('body').text)
AssertionError: 'Django administration' not found in 'Page not found 
(404)\nRequest Method: GET\nRequest URL: 
http://localhost:8081/admin\n"admin"; does not exist\nYou\'re seeing this 
error because you have DEBUG = True in your Django settings file. Change 
that to False, and Django will display a standard 404 page.'

I'm just using the admin URL because it's one that is activated by 
default.  Normal URLs, eg a home page view, also return 404s.  What's going 
on?



-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/eb0d8b58-ea5c-4d7a-9c2a-d302d4adc3ae%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to