Hi guys,

I have django 1.6.1 project which uses django rest framework and I work 
around building api. I covered api calls by unittests and I have one 
problem.
Application name is 'api' and all tests are passed when I run tests using 
command:

python manage.py test api

But when I run all project tests without specifying application name, tests 
are failing with error 

======================================================================
ERROR: test_get_contract_list (someproj.api.tests.ContractAPITestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/user/Projects/someproj/api/tests.py", line 44, in 
test_get_contract_list
    url = reverse('api:rest_api_contracts')
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 
505, in reverse
    key)
NoReverseMatch: u'api' is not a registered namespace


In my tests I'm using 'reverse' method from django.core.urlresolvers for 
getting urls for tests, for example:

url = reverse('api:rest_api_contracts')

In my root urlconf I have this pattern:

url(r'^api/', include('someproj.api.urls', namespace='api')),

and in my application urlconf:

url(r'^contracts/$', views.ContractListAPIView.as_view(), 
name='rest_api_contracts'),

So, why tests are failed when I run it without specifying app name? 
Method 'reverse' works fine when I run tests with application name as 
parameter and works fine in shell as well.


Regards,
Danil Galeev

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2aa400f8-ae20-4a23-ba5e-43922985dfc9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to