Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6613519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:13:41+00:00 2026-05-25T20:13:41+00:00

Python 2.7 Django 1.2 I am getting odd local_settings behavior when I am testing

  • 0

Python 2.7
Django 1.2

I am getting odd local_settings behavior when I am testing a Django app. I have my <project>/settings.py set up like this:

DEBUG = False
TEMPLATE_DEBUG = DEBUG

ADMINS = (
        ("Me", "me@me.com"),
)

MANAGERS = ADMINS + (('Person1', 'person1@blah.com'),)

# ... rest of settings

try:
    from local_settings import *
except ImportError:
    pass

and in <project>/local_settings.py I have:

DEBUG = True

MANAGERS = (
        ('Me', 'me@me.com'),
)

So, while working locally, the MANAGERS setting should be (('Me', 'me@me.com'),), and DEBUG should be set to True.

However, in the tests for one of my apps, I am testing settings.DEBUG and getting False, but the MANAGERS setting is set correctly (it just has ‘Me’ in it). Any ideas why this would happen? Here are the relevant parts of the <project>/<app>/tests.py file:

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

# ...
class MyTests(TestCase):
    def mytest(self):
        if settings.DEBUG:
            self.assertEqual(settings.MANAGERS, (('Me', 'me@me.com'),))
        else:
            self.assertEqual(settings.MANAGERS, (('Me', 'me@me.com'), ('Person1', 'person1@blah.com')))

The result is

AssertionError: (('Me', 'me@me.com'),) != (('Me', 'me@me.com'), ('Person1', 'person1@blah.com'))

So it looks like it is testing the else branch due to settings.DEBUG being set incorrectly, and then raising AssertionError since settings.MANAGERS is set correctly.

If I run python manage.py shell I get this:

>>> from django.conf import settings
>>> settings.DEBUG
True
>>> settings.MANAGERS
(('Me', 'me@me.com'),)

So they are set correctly there.

I know I can override settings manually in my tests, but I wanted to try to use settings.DEBUG so that the test would pass no matter whether it was being run locally or in production.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:13:41+00:00Added an answer on May 25, 2026 at 8:13 pm

    This is an intentional choice within Django:

    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.

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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Running Django Nonrel, with Google App Engine 2.6.0 and Python 2.7, I'm getting this
I need to have an at-home project now that I'm working on Python/Django at
I having issues getting Django to work with settings.py at different location I have
Django 1.1.2 & Python 2.6.5 I keep getting this error when executing a seemingly
I'm using python, django and google app engine and I'm getting the error below.
I am python/django developer. As a part of improving my knowledge and felt like
I have built Web sites with Python/Django and desktop applications with Objective-C/Cocoa so programming
I am working on a web application using Python (Django) and would like to
I program Django/Python in emacs, and I would like things like {% comment %}
I'm getting the following error: Template error In template /home/mo/python/django/templates/yoga/index.html, error at line 1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.