#7521 closed (fixed)
auth/tests fail on custom project with "manage.py 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 |
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 (1)
Change History (18)
comment:1 by , 17 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:2 by , 17 years ago
Component: | Authentication → Unit test system |
---|---|
milestone: | → 1.0 alpha |
Resolution: | worksforme |
Status: | closed → reopened |
Triage Stage: | Unreviewed → Accepted |
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().
comment:3 by , 17 years ago
Summary: | auth/tests fails → auth/tests fail on custom project with "manage.py test" |
---|
comment:4 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:5 by , 17 years ago
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.
comment:6 by , 17 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Triage Stage: | Accepted → 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.
comment:7 by , 17 years ago
Owner: | set to |
---|---|
Status: | reopened → new |
Triage Stage: | Design decision needed → 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.
comment:8 by , 17 years ago
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.
comment:9 by , 17 years ago
comment:10 by , 16 years ago
milestone: | 1.0 alpha → 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.
comment:11 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:12 by , 16 years ago
comment:13 by , 16 years ago
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 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Version: | SVN → 1.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 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
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 by , 16 years ago
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.
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.