Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set DEBUG to True when running a Django test?

Tags:

django

I'm currently running some Django tests and it looks that DEBUG=False by default. Is there a way to run a specific test where I can set DEBUG=True at the command line or in code?

like image 885
Thierry Lam Avatar asked Sep 16 '11 15:09

Thierry Lam


People also ask

What is debug true in Django?

The debug mode (DEBUG=True) is turned on by default in the Django framework. It provides a detailed traceback with the local variables to find out the error with the line numbers. The error can be triggered from the view page by setting the value of assert to False in the view file.


1 Answers

For a specific test inside a test case, you can use the override_settings decorator:

from django.test.utils import override_settings from django.conf import settings class TestSomething(TestCase):     @override_settings(DEBUG=True)     def test_debug(self):         assert settings.DEBUG 
like image 70
ferrouswheel Avatar answered Oct 07 '22 14:10

ferrouswheel