Django CMS test - can't find namespace
Question: I've got a very strange problem with Django CMS tests. When I run:
`./manage.py test --settings=my_project.test_settings` I get that error:

> ERROR: test_guest_list_view (apps.news.tests.test_views.NewsListViewTest)
> Tests if guest can't see disabled entries
> \----------------------------------------------------------------------
> Traceback (most recent call last): File
> "/home/robert/work/projects/my_project/apps/news/tests/test_views.py", line
> 52, in test_guest_list_view response = self.client.get(self._get_list_url())
> File "/home/robert/work/projects/my_project/apps/news/tests/test_views.py",
> line 17, in _get_list_url return reverse("news:list") File
> "/home/robert/.virtualenvs/my_project/local/lib/python2.7/site-
> packages/django/core/urlresolvers.py", line 532, in reverse key)
> NoReverseMatch: u'news' is not a registered namespace

**But when I ran tests only for that app everything works fine - all tests
pass.**

That's my very simple test class so far:

    
    
    # -*- coding: utf-8 -*-
    from django.contrib.auth.models import Permission
    from django.contrib.contenttypes.models import ContentType
    from django.core.urlresolvers import reverse
    from django.test.utils import override_settings
    
    from cms.test_utils.testcases import CMSTestCase
    
    from apps.accounts.tests.factories import CustomUserFactory
    from .factories import NewsFactory
    from ..models import News
    
    
    class BaseNewsTestCase(CMSTestCase):
        def _get_list_url(self):
            """Returns URL to objects list"""
            return reverse("news:list")
    
        def _create_data_structure(self):
            """Created test data"""
            # add objects
            self.disabled = NewsFactory(is_visible=False)
            self.enabled = NewsFactory()
            NewsFactory()
            NewsFactory()
    
            self.user = CustomUserFactory(username='user', password='user')
    
            # privileged_user
            self.privileged_user = CustomUserFactory(username='p_user',
                                                     password='p_user')
    
            # add permissions
            content_type = ContentType.objects.get_for_model(News)
            permissions_list = ('add_news', 'change_news', 'delete_news')
            permissions = Permission.objects.filter(content_type=content_type,
                                                    codename__in=permissions_list)
    
            self.privileged_user.user_permissions.add(*permissions)
    
    
    @override_settings(ROOT_URLCONF='apps.news.tests.urls')
    class NewsListViewTest(BaseNewsTestCase):
        def test_guest_list_view(self):
            """Tests if guest can't see disabled entries"""
            self._create_data_structure()
    
            response = self.client.get(self._get_list_url())
            objects = response.context['object_list']
    
            self.assertEqual(len(objects), 3)
            for obj in objects:
                self.assertNotEqual(obj, self.disabled)
    

and test urls:

    
    
    # -*- coding: utf-8 -*-
    from django.contrib import admin
    from django.conf.urls import url, patterns, include
    
    urlpatterns = patterns(
        '',
        url(r'^admin/', include(admin.site.urls)),
        url(r'^news/', include('apps.news.urls', namespace='news')),
        url(r'', include('cms.urls')),
    )
    

Any clue what can cause that problem? I follow this, to test my CMA apphook
(<http://django-cms.readthedocs.org/en/latest/extending_cms/testing.html>)

I have the same tests pattern in different app in that project but it doesn't
throw that error.


Answer: I found a solution. Instead of using
`@override_settings(ROOT_URLCONF='myapp.tests.urls')` for my TestCases, as
suggested in [Django CMS docs](http://django-
cms.readthedocs.org/en/latest/extending_cms/testing.html#resolving-view-names)
I used the Django way found
[here](https://docs.djangoproject.com/en/1.6/topics/testing/tools/#django.test.SimpleTestCase.urls).

So for each TestCase I do this, for example:

    
    
    class NewsListViewTest(CMSTestCase):
        urls = 'apps.news.tests.urls'
    

