#15988 closed Cleanup/optimization (fixed)
django.contrib.contenttypes.tests.ContentTypesTests.test_shortcut_view doesn't handle ABSOLUTE_URL_OVERRIDES
Reported by: | paltman | Owned by: | nobody |
---|---|---|---|
Component: | contrib.contenttypes | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
When using ABSOLUTE_URL_OVERRIDES setting, the shortcut_view_test causes test failures.
For example, I have:
ABSOLUTE_URL_OVERRIDES = { "auth.user": lambda o: "/profiles/profile/%s/" % o.username, }
and so when running ./manage.py test I get:
====================================================================== FAIL: test_shortcut_view (django.contrib.contenttypes.tests.ContentTypesTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/patrick/.virtualenvs/vv/lib/python2.7/site-packages/django/contrib/contenttypes/tests.py", line 70, in test_shortcut_view response._headers.get("location")[1]) AssertionError: u'http://mydomain.o1.gondor.io/users/john/' != 'http://mydomain.o1.gondor.io/profiles/profile/john/'
I expected this test to handle the case of ABSOLUTE_URL_OVERRIDES being used.
Attached is my patch to the test to match this expectation.
Attachments (3)
Change History (9)
by , 14 years ago
Attachment: | fix-contenttypes-test.diff added |
---|
by , 14 years ago
Attachment: | fix-contenttypes-test.2.diff added |
---|
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
Patch does not apply cleanly—it was probably not done against trunk.
trunk % patch -p1 < fix-contenttypes-test.2.diff patching file django/contrib/contenttypes/tests.py Hunk #1 succeeded at 85 with fuzz 2 (offset 20 lines).
I'm attaching a patch which shows another way of fixing this.
by , 14 years ago
Attachment: | 15990.patch added |
---|
comment:3 by , 14 years ago
Damn. I can't dig the original patch out of Time Machine.
If I remember correctly, I suggested to unset ABSOLUTE_URL_OVERRIDES
for the duration of the test. We're not testing that ABSOLUTE_URL_OVERRIDES
works properly here, and we don't want the tests to depend on user settings.
This can be done nicely since r16237.
comment:4 by , 13 years ago
Patch needs improvement: | set |
---|---|
UI/UX: | unset |
Patch needs improvement as per the comments above.
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I guess that [a6c08a53d37cd91f2073f8744539a4297fd652f3] also fixed this issue.
corrected typo