[Answered ]-Django: check whether run as development or production when testing?

2👍

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

Regardless of the value of the DEBUG setting in your configuration file, all Django tests run with DEBUG=False. This is to ensure that the observed output of your code matches what will be seen in a production setting.

I would suggest you write your test differently. The purpose is to test the functionality of the code as it would run in production, so there should be no need to check the value of DEBUG.

👤ChidG

Leave a comment