On Tue, Oct 11, 2011 at 5:32 AM, Justin Holmes <[email protected]> wrote:
> contrib.auth.tests.views line 28 overrides settings.TEMPLATE_DIRS
> causing tests to fail for signal hooks that use templates in locations
> specified in settings.TEMPLATE_DIRS.
>
> Is this a bug?  I can't immediately see the reason for overriding
> here.  I understand that the test runner needs its own templates, but
> why not just add this location to the tuple?  At very least, it causes
> in an unexpected result.

The reason for overriding TEMPLATE_DIRS is to keep the tests isolated.
The theory is that it shouldn't matter what templates you have in your
production setup; the auth tests should be self contained.

The traditional way this manifests is with the login page template --
if you had a project that *didn't* deploy the standard login view, the
auth tests would fail because they couldn't find the login template
for the standard login view when that view was tested.

We can't just add an extra location to the tuple because we still end
up with an unpredictable environment -- consider the case where we are
testing the fact that a template *doesn't* exist, but your production
environment provides one.

The full fix here is to provide better environment isolation during
testing. Ideally, we should be constructing a completely clean
settings object for every test run, explicitly introducing the extra
settings that we need (rather than the current model taking system
settings, and 'fixing' the settings that are problematic). Ideally,
this would be a full 'system flush', including settings app caches,
and every other runtime singleton that Django uses. However, this is a
non-trivial piece of work. A very *useful*, non-trivial piece of work,
but still non-trivial :-)

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to