Django

Code

Ticket #7521 (closed: fixed)

Opened 4 months ago

Last modified 3 months ago

auth/tests fail on custom project with "manage.py test"

Reported by: anonymous Assigned to: telenieko
Milestone: 1.0 Component: Testing framework
Version: SVN Keywords: test failure
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The auth/tests.py, which evidently was added yesterday, produces some failed assertions when enacted by 'python manage.py 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/tests.py", 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/tests.py", line 64, in test_email_not_found
    self.assertEquals(response.status_code, 200)
AssertionError: 404 != 200

----------------------------------------------------------------------

Attachments

7521.diff (6.0 kB) - added by telenieko on 06/26/08 06:57:19.
Patch to allow "urls" parameter on tests.

Change History

06/22/08 00:54:38 changed by russellm

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to worksforme.
  • needs_tests changed.
  • needs_docs changed.

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.

06/22/08 05:53:26 changed by telenieko

  • status changed from closed to reopened.
  • resolution deleted.
  • stage changed from Unreviewed to Accepted.
  • component changed from Authentication to Unit test system.
  • milestone set to 1.0 alpha.

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

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().

06/22/08 05:53:58 changed by telenieko

  • summary changed from auth/tests fails to auth/tests fail on custom project with "manage.py test".

06/23/08 07:17:58 changed by russellm

  • status changed from reopened to closed.
  • resolution set to fixed.

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

06/23/08 15:39:19 changed by dek <dan.kelley@dal.ca>

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

Dan.

06/24/08 12:07:35 changed by telenieko

  • status changed from closed to reopened.
  • resolution deleted.
  • stage changed from Accepted to Design 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 runtests.py

I can think about two options right now:

  • manage.py test should not run test for contrib apps, they're already tested by runtests.py by django developers.
  • manage.py 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.

06/25/08 18:04:08 changed by telenieko

  • owner set to telenieko.
  • status changed from reopened to new.
  • stage changed from Design decision needed to Accepted.

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.

06/26/08 06:57:19 changed by telenieko

  • attachment 7521.diff added.

Patch to allow "urls" parameter on tests.

06/26/08 07:00:12 changed by telenieko

  • has_patch set to 1.

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

06/27/08 04:44:29 changed by telenieko

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

06/27/08 10:00:12 changed by garcia_marc

  • milestone changed from 1.0 alpha to 1.0.

According to ticket organization defined in http://code.djangoproject.com/wiki/VersionOneRoadmap#how-you-can-help 1.0 alpha tickets should be just features in the Must have (http://code.djangoproject.com/wiki/VersionOneRoadmap#must-have-features) list.

As bug, it should be fixed before 1.0 milestone.

06/30/08 07:34:29 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(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.

06/30/08 08:11:13 changed by russellm

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


Add/Change #7521 (auth/tests fail on custom project with "manage.py test")




Change Properties
Action