1

I am using Django==1.7.11, mysql, python 2.7.

In my settings file I have debug set to True, I've confirmed this by entering the django shell and consistently I get True.

>>> from django.conf import settings
>>> settings.DEBUG
True

But in my tests.py file:

import unittest

from django.conf import settings
import settings as settingsfile
from django.test import LiveServerTestCase

class SeleniumTest(LiveServerTestCase):

    def test_nothing(self):
        print 'File DEBUG is: %s' % (settingsfile.DEBUG, )
        print 'Django DEBUG is: %s' % (settings.DEBUG, )

if __name__ == '__main__':
    unittest.main()

>>>> File DEBUG is: True
>>>> Django DEBUG is: False

Is there anywhere else that the value of DEBUG could have changed or some misuse of importing settings in test files that I'm not aware of??

== UPDATE ==

This link mentions that LiveServerTestCase forces DEBUG=False so that it mimics a production server but I changed my file to use Django's normal TestCase and end up with the same results.

import unittest

from django.conf import settings
from django.test import TestCase
import settings as settingsfile

class SeleniumTest(TestCase):

    def test_nothing(self):
        print 'File DEBUG is: %s' % (settingsfile.DEBUG, )
        print 'Django DEBUG is: %s' % (settings.DEBUG, )

if __name__ == '__main__':
    unittest.main()

>>>> File DEBUG is: True
>>>> Django DEBUG is: False
ishikun
  • 428
  • 5
  • 21

1 Answers1

3

Django's tests run with DEBUG=False.

https://docs.djangoproject.com/en/dev/topics/testing/overview/#other-test-conditions

ishikun
  • 428
  • 5
  • 21