Opened 14 years ago

Closed 12 years ago

Last modified 12 years ago

#15988 closed Cleanup/optimization (fixed)

django.contrib.contenttypes.tests.ContentTypesTests.test_shortcut_view doesn't handle ABSOLUTE_URL_OVERRIDES

Reported by: Patrick Altman 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)

fix-contenttypes-test.diff (1.1 KB ) - added by Patrick Altman 14 years ago.
fix-contenttypes-test.2.diff (1.1 KB ) - added by anonymous 14 years ago.
corrected typo
15990.patch (993 bytes ) - added by Aymeric Augustin 14 years ago.

Download all attachments as: .zip

Change History (9)

by Patrick Altman, 14 years ago

Attachment: fix-contenttypes-test.diff added

by anonymous, 14 years ago

corrected typo

comment:1 by Aymeric Augustin, 14 years ago

Triage Stage: UnreviewedAccepted

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 Aymeric Augustin, 14 years ago

Attachment: 15990.patch added

comment:2 by dmclain, 14 years ago

aaugustin: looks like you accidentally uploaded the wrong patch.

comment:3 by Aymeric Augustin, 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 Julien Phalip, 14 years ago

Patch needs improvement: set
UI/UX: unset

Patch needs improvement as per the comments above.

comment:5 by Claude Paroz, 12 years ago

Resolution: fixed
Status: newclosed

I guess that [a6c08a53d37cd91f2073f8744539a4297fd652f3] also fixed this issue.

comment:6 by Claude Paroz <claude@…>, 12 years ago

In [2c2c8a63266b586e3782267fb361504e5ac05abe]:

Isolated sitemaps test from ABSOLUTE_URL_OVERRIDES

Refs #15988.

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