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 8717469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:18:46+00:00 2026-06-13T06:18:46+00:00

I maintain an installable Django app that includes a regular test suite. Naturally enough

  • 0

I maintain an installable Django app that includes a regular test suite.

Naturally enough when project authors run manage.py test for their site, the tests for both their own apps and also any third party installed apps such as mine will all run.

The problem that I’m seeing is that in several different cases, the user’s particular settings.py will contain configurations that cause my app’s tests to fail.

A couple of examples:

  • Some of the tests need to check for returned error messages. These error messages use the internationalization framework, so if the site language is not english then these tests fail.
  • Some of the tests need to check for particular template output. If the site is using customized templates (which the app supports) then the tests will end up using their customized templates in preference to the defaults, and again the tests will fail.

I want to try to figure out a sensible approach to isolating the environment that my tests get run with in order to avoid this.

My plan at the moment is to have all my TestCase classes extend a base TestCase, which overrides the settings, and any other environment setup I may need to take care of.

My questions are:

  • Is this the best approach to app-level test-environment isolation? Is there an alternative I’ve missed?
  • It looks like I can only override a setting at a time, when ideally I’d probably like a completely clean configuration. Is there be a way to do this, and if not which are the main settings I need to make sure are set in order to have a basic clean setup?
  • I believe I’m correct in saying that overriding some settings such as INSTALLED_APPS may not actually affect the environment in the expected way due to implementation details, and global state issues. Is this correct? Which settings do I need to be aware of, and what globally cached environment information may not be affected as expected?
  • What other environment state other than settings might I need to ensure is clean?

More generally, I’d also be interested in any context regarding how much of an issue this is for other third party installable apps, or if there are any plans to further address any of this in core. I’ve seen conversation on IRC regarding similar issues with eg. some of Django’s contrib apps running under unexpected settings configurations. I seem to also remember running into similar cases with both third party apps and django contrib apps a few times, so it feels like I’m not alone in facing these kind of problems, but it’s not clear if there’s a consensus on if this is something that needs more work or if the status quo is good enough.

Note that:

  • These are integration-level tests, so I want to address these environment issues at the global level.
  • I need to support Django 1.3, but can put in some compatibility wrappers so long as I’m not re-implementing massive amounts of Django code.
  • Obviously enough, since this is an installable app, I can’t just specify my own DJANGO_SETTINGS_MODULE to be used for the tests.
  • 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-06-13T06:18:48+00:00Added an answer on June 13, 2026 at 6:18 am

    A nice approach to isolation I’ve seen used by Jezdez is to have a submodule called my_app.tests which contains all the test code (example). This means that those tests are NOT run by default when someone installs your app, so they don’t get random phantom test failures, but if they want to check that they haven’t inadvertently broken something then it’s as simple as adding myapp.tests to INSTALLED_APPS to get it to run.

    Within the tests, you can do your best to ensure that the correct environment exists using override_settings (if this isn’t in 1.4 then there’s not that much code to it). Personally my feeling is that with integration type tests perhaps it doesn’t matter if they fail. If you like, you can include a clean settings file (compressor.test_settings), which for a major project may be more appropriate.

    An alternative is that you separate your tests out a bit – there are two separate bodies of tests for contrib.admin, those at django.contrib.admin.tests, and those at tests.regression_tests.contrib.admin (or some path like that). The ones to check public apis and core functionality (should) reside in the first, and anything likely to get broken by someone else’s (reasonable) configuration resides in the second.

    IMHO, the whole running external apps tests is totally broken. It certainly shouldn’t happen by default (and there are discussions to that effect) and it shouldn’t even be a thing – if someone’s external app test suite is broken by my monkey patching (or whatever) I don’t actually care – and I definitely don’t want it to break the build of my site. That said, the above approaches allow those who disagree to run them fairly easily. Jezdez probably has as many major pluggable apps as anyone else, and even if there are some subtle issues with his approach at least there is consistency of behaviour.

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

Sidebar

Related Questions

I maintain a Django project with a database that has several model constraints that
I maintain a test suite utilizing Selenium and Capybara. While I can convince Selenium
I maintain Autoit project used for automated testing of swing app. Those tests have
I maintain a project that has a function definition similar to this: def f(a,
I maintain a project that is versioned with Mercurial and managed with Maven. When
I maintain an applet that helps users to upload photos to our service. The
We maintain a DLL that does a lot of system-related things; traversing the file
I maintain a farmer market site. Part of the site includes a database with
I maintain a Python program that provides advice on certain topics. It does this
I maintain (but didn't develop) ASP site that has a comments form on its

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.