Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#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)

fix-contenttypes-test.diff (1.1 KB) - added by paltman 4 years ago.
fix-contenttypes-test.2.diff (1.1 KB) - added by anonymous 4 years ago.
corrected typo
15990.patch (993 bytes) - added by aaugustin 4 years ago.

Download all attachments as: .zip

Change History (9)

Changed 4 years ago by paltman

Changed 4 years ago by anonymous

corrected typo

comment:1 Changed 4 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to 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.

Changed 4 years ago by aaugustin

comment:2 Changed 4 years ago by dmclain

aaugustin: looks like you accidentally uploaded the wrong patch.

comment:3 Changed 4 years ago by aaugustin

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 Changed 4 years ago by julien

  • Patch needs improvement set
  • UI/UX unset

Patch needs improvement as per the comments above.

comment:5 Changed 3 years ago by claudep

  • Resolution set to fixed
  • Status changed from new to closed

I guess that [a6c08a53d37cd91f2073f8744539a4297fd652f3] also fixed this issue.

comment:6 Changed 3 years ago by Claude Paroz <claude@…>

In [2c2c8a63266b586e3782267fb361504e5ac05abe]:

Isolated sitemaps test from ABSOLUTE_URL_OVERRIDES

Refs #15988.

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