Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#22213 closed Bug (worksforme)

Test failure: relative path in resolve_url

Reported by: afuna Owned by: nobody
Component: Testing framework Version: 1.6
Severity: Normal Keywords:
Cc: django@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Running against master:

➤ python tests/ resolve_url.tests.ResolveUrlTests
Testing against Django installed in 'code/django/django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...

ERROR: test_relative_path (resolve_url.tests.ResolveUrlTests)
Traceback (most recent call last):
  File "code/django/tests/resolve_url/", line 29, in test_relative_path
    self.assertEqual('../', resolve_url('../'))
  File "code/django/django/shortcuts/", line 151, in resolve_url
  File "code/django/django/core/", line 515, in reverse
    return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
  File "code/django/django/core/", line 387, in _reverse_with_prefix
    lookup_view = get_callable(lookup_view, True)
  File "code/django/django/utils/", line 101, in wrapper
    result = user_function(*args, **kwds)
  File "code/django/django/core/", line 96, in get_callable
    mod = import_module(mod_name)
  File "python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/", line 30, in import_module
    raise TypeError("relative imports require the 'package' argument")
TypeError: relative imports require the 'package' argument

Looks to have been introduced in 8251438cb8c1d47779e9fc33cfa84dad9851a774

Change History (6)

comment:1 Changed 21 months ago by bmispelon

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset


The test pass on my machine and on our CI server (

Did you make sure to run git clean -fdx to get a clean checkout (warning: this will delete any uncommited change and untracked file in the repository).
Sometimes, leftover .pyc files can make some tests fail and this command will delete them.

If that still fails, can you give some more details about your configuration (your OS for example)?


comment:2 Changed 21 months ago by bmispelon

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

(please reopen with more details if my previous comment didn't work)

comment:3 Changed 21 months ago by Keryn Knight <django@…>

To chime in with an anecdotal report: a user on IRC encountered the same test failure (or similar one raising the same TypeError) recently, but neither I nor the CI could reproduce the error. That user was running OSX (as I do), which the above traceback seems to match.

comment:4 Changed 21 months ago by bmispelon

I noticed that the way the tests are run (python tests/ resolve_url.tests.ResolveUrlTests) doesn't match what we recommend in

Does changing that fix the issue?

comment:5 Changed 21 months ago by Keryn Knight <django@…>

  • Cc django@… added

To provide some more context to my earlier comment, the user I was referring to was __machine on IRC, which I think is the Trac user mrmachine. Meanwhile I've run python tests/ resolve_url.tests.ResolveUrlTests (ie: the unrecommended way of running it) on OSX 10.8.4 with Python 2.7.6 via Homebrew and am unable to replicate the error reported.

comment:6 Changed 21 months ago by afuna

It looks like it was the leftover .pyc files after all, thanks all, and sorry for the noise!

For further context: python tests/ vs cd tests; python didn't seem to have any bearing. I originally ran into the test failure while running the test suite the normal way, and went to the toplevel directory so I could run git bisect.

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