Value of settings.DEBUG changing between settings and url in Django Test
<p>I'm trying to set up test for some URLS that are set only in debug. They are not set because apparently the value of DEBUG change to False between my setting file and urls.py. I've never encountered this problem before, and I don't remember doing anything particularly fancy involving DEBUG value.</p>

<p>Here's my urls.py :</p>

<pre><code>from django.conf import settings
from my_views import dnfp
print "settings.DEBUG in url: {}".format(settings.DEBUG)
if settings.DEBUG:
    urlpatterns += [url(r'^dnfp/$', dnfp, name="debug_not_found_page"...
</code></pre>

<p>Here's my setting file :</p>

<pre><code>DEBUG=True
print "DEBUG at the end of the settings: {}".format(DEBUG)
</code></pre>

<p>The content that fail in my test :</p>

<pre><code> reverse("debug_not_found_page"), 
</code></pre>

<p>Here's the output of the test :</p>

<pre><code>DEBUG at the end of the settings: True
settings.DEBUG in url: False
Creating test database for alias 'default'...
.E
(...)
NoReverseMatch: Reverse for 'debug_not_found_page' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
</code></pre>

<p>If I change the value myself in urls.py the url is set again and the test works with this urls.py :</p>

<pre><code>from django.conf import settings
from my_views import dnfp
settings.DEBUG = True
if settings.DEBUG:
    urlpatterns += [url(r'^dnfp/$', dnfp, name="debug_not_found_page"...
</code></pre>

<p>Any ideas when and why my value for DEBUG is changing between settings and urls ?</p>

<p>From the <a href="https://docs.djangoproject.com/en/1.10/topics/testing/overview/#other-test-conditions" rel="nofollow">docs</a></p>

<blockquote>
  <p>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.</p>
</blockquote>

python django testing