Opened 11 years ago

Closed 10 years ago

Last modified 7 years ago

#7521 closed (fixed)

auth/tests fail on custom project with " test"

Reported by: anonymous Owned by: Marc Fargas
Component: Testing framework Version: 1.1-beta
Severity: Keywords: test failure
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The auth/, which evidently was added yesterday, produces some failed assertions when enacted by 'python test':

FAIL: test_email_found (django.contrib.auth.tests.PasswordResetTest)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/auth/", line 71, in test_email_found
    self.assertEquals(response.status_code, 302)
AssertionError: 404 != 302

FAIL: test_email_not_found (django.contrib.auth.tests.PasswordResetTest)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/auth/", line 64, in test_email_not_found
    self.assertEquals(response.status_code, 200)
AssertionError: 404 != 200


Attachments (1)

7521.diff (6.0 KB) - added by Marc Fargas 11 years ago.
Patch to allow "urls" parameter on tests.

Download all attachments as: .zip

Change History (18)

comment:1 Changed 11 years ago by Russell Keith-Magee

Resolution: worksforme
Status: newclosed

I'm not seeing this failure and the buildbot agrees. As at [7722], there is a failure in the tests, but it is in a different test to the one you are reporting.

comment:2 Changed 11 years ago by Marc Fargas

Component: AuthenticationUnit test system
milestone: 1.0 alpha
Resolution: worksforme
Status: closedreopened
Triage Stage: UnreviewedAccepted

Not exacly, If you run "./ test" on a project which has contrib.auth in INSTALLED_APPS, django will run the contrib.auth tests, and the required by those tests is not included in this case (the needed will only be included if you are running with

So anybody using the test framework on his project, whith contrib.auth installed is likely to have problems.

An option would be the TestCase of contrib.auth to add the needed URL's on setUp().

comment:3 Changed 11 years ago by Marc Fargas

Summary: auth/tests failsauth/tests fail on custom project with " test"

comment:4 Changed 11 years ago by Russell Keith-Magee

Resolution: fixed
Status: reopenedclosed

(In [7726]) Fixed #7521 -- Reverted [7716]. Fixed URLs in test case broke any application that deployed contrib.auth.

comment:5 Changed 11 years ago by dek <dan.kelley@…>

I'm not sure if it's ok for me to add a comment to a closed issue, but I just wanted to say, as the original reporter, that

1) this works for me now

2) thanks very much for the quick bug fix


comment:6 Changed 11 years ago by Marc Fargas

Resolution: fixed
Status: closedreopened
Triage Stage: AcceptedDesign decision needed

I don't think we should consider this fixed, the bug here is that Contrib applications cannot test their on views, because there's no guarantee that user project's will include the contrib app urls. Which will then make those tests fails (that's what happened after [7716] with contrib.auth).

And it seems reasonable that contrib apps should be able to, somehow, test their views when using

I can think about two options right now:

  • test should not run test for contrib apps, they're already tested by by django developers.
  • tests should, somehow, make sure the needed urls are there or disable the tests that would fail otherwise.

I'd really be on option 1, I don't see the point on running tests for contrib apps from the user project when those apps, in theory, have already been tested.

I'll post this to django-developers, and mark as DDN. Just commenting there to leave track.

comment:7 Changed 11 years ago by Marc Fargas

Owner: set to Marc Fargas
Status: reopenednew
Triage Stage: Design decision neededAccepted

Brought for discussion here seems to be consensus on providing a way for TestCases to orverride the root urlconf on setup and bring the original urlconf back on teardown.

Apparently formtools already do this.

Changed 11 years ago by Marc Fargas

Attachment: 7521.diff added

Patch to allow "urls" parameter on tests.

comment:8 Changed 11 years ago by Marc Fargas

Has patch: set

Attached a patch which allows a "urls" parameter on TestCase, some other things were added:

  • Added clear_url_caches() to django.core.urlresolvers (We need to clear the cache when changing URLconfs)
  • Changed formtools.tests to use the new "urls" parameter instead of it's own hack (which could break for the cache).
  • Added two TestCase to check this works, and documentation.

Note that [7716] should be brought back after this gets in, with a new urls parameter.

NOTE: Also available on git: gitweb, git

comment:9 Changed 11 years ago by Marc Fargas

The diff for getting back [7716] using the urls parameter is here. I'll attach if needed.

comment:10 Changed 11 years ago by Marc Garcia

milestone: 1.0 alpha1.0

According to ticket organization defined in 1.0 alpha tickets should be just features in the Must have ( list.

As bug, it should be fixed before 1.0 milestone.

comment:11 Changed 11 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [7805]) Fixed #7521 -- Added the ability to customize ROOT_URLCONF for the duration of a TestCase. Thanks to Mark Fargas (telenieko) for his work on this patch.

comment:12 Changed 11 years ago by Russell Keith-Magee

(In [7808]) Refs #7521 -- Re-reverted [7716] (originally reverted in [7726]), now modified to use the new TestCase urlpattern framework.

comment:13 Changed 10 years ago by siddhi

There is still a problem here. I have the auth app installed, but I've customised the templates. It so happens that the template has a reverse lookup to some urls defined in my ROOT_URLCONF. Because the unit test case overrides my urls, the reverse lookup fails and the template rendering also fails (raises a NoReverseMatch exception) and the unit test fails.

comment:14 Changed 10 years ago by fnl

Resolution: fixed
Status: closedreopened
Version: SVN1.1-beta-1

Having the same problems as siddhi. Why are the authentication tests there at all, especially, things like self.assert_("Please enter your new password" in response.content) should not be part of the base django dango distribution, at least not in the beta or stable - I'm having problems to test my apps with (1, 1, 0, 'beta', 1) because I always have to first remove the useless tests and replace them with something that works for me.

comment:15 Changed 10 years ago by Malcolm Tredinnick

Resolution: fixed
Status: reopenedclosed

comment:13 seems to be reporting a version of #8404. This ticket has already been resolved. If there is a new problem that is not the same as #8404 (or some other existing ticket), please open a new ticket so that the problem tracking history is straight. Realise that "I do not think the tests for an application I have installed should be run at all" is not a bug report (comment:14). Improvements welcome; suggestions to now test things, not so much. Reclosing.

comment:16 Changed 10 years ago by fnl

Ok, sorry for adding this into the wrong ticket - moved this issue to #8404, as it fits quite well with that description. I think tests that force you to use the English language and an overly specific implementation schema should not be part of the Django base distribution (see my comments there) - however, I am not trying to say "do not run tests for installed apps" as suggested by comment:15, what I am arguing is that in the base distribution there must be a sensible amount of freedom of choice for the implementation, e.g. language and phrase usage restrictions made through tests provided by the base distribution are misplaced.

comment:17 Changed 7 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top