I am struggling to get 'reverse' working when running tests for actions defined in my admin.py files.
If I open a Django shell and run: from django.core.urlresolvers import reverse print reverse('admin:trees_alivetrees_changelist') I get: /admin/trees/alivetrees/ as expected. But if I define a test file (called `test_admin_fail.py`): from django.test import TestCase from django.core.urlresolvers import reverse class TreeAdminTest(TestCase): def test_action_tree_mark_dead(self): change_url = reverse('admin:trees_alivetrees_changelist') self.assertContains(change_url, "alivetrees") # temporary test and run it from the command line: python manage.py test --traverse-namespace tests.trees.test_admin_fail -v 2 --settings=test_settings then I get this error: Traceback (most recent call last): File "/dev/tests/trees/test_admin_fail.py", line 7, in test_action_tree_mark_dead change_url = reverse('admin:trees_alivetrees_changelist') File "/.virtualenvs/s2/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 536, in reverse return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)) File "/home/derek/.virtualenvs/s2/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 456, in _reverse_with_prefix (lookup_view_s, args, kwargs, len(patterns), patterns)) NoReverseMatch: Reverse for 'trees_alivetrees_changelist' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] -------------------- >> begin captured stdout << --------------------- nose.proxy:128 err (<class 'django.core.urlresolvers.NoReverseMatch'>, NoReverseMatch(u"Reverse for 'trees_alivetrees_changelist' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []",), <traceback object at 0x7fe779406c20>) The test_settings.py file is used to create an in-memory database (and has never itself caused any issues before). Any guidance here would be appreciated; I have tried Googling for the error, but the combination of admin, testing and reverse is one I have not seen. Thanks Derek -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF1Wu3P7QKBwoPZJUDYePn1OVsgoQA0GCks%2BXEtJyC1iKbG3-w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.