diff --git a/HISTORY.rst b/HISTORY.rst index 380891ecda..ad0324fbe3 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,6 +12,8 @@ * Apply merge !35 by Manoel Brunnen (@mbru) to fix building the Docker image on the armv7l platform (RasperryPi, Odroid XU4, Odroid HC2). Also fixes assertion errors from pip (https://github.com/pypa/pip/issues/6197). +* Apply merge !37 by Roger Hunwicks (@roger.hunwicks) to allow + TestViewTestCaseMixin to work with a custom ROOT_URLCONF. GitLab issue #566. 3.1.9 (2018-11-01) ================== diff --git a/mayan/apps/common/tests/base.py b/mayan/apps/common/tests/base.py index 91a2b611b9..9a40f9f829 100644 --- a/mayan/apps/common/tests/base.py +++ b/mayan/apps/common/tests/base.py @@ -1,4 +1,5 @@ from __future__ import absolute_import, unicode_literals +import importlib from django.test import TestCase diff --git a/mayan/apps/common/tests/mixins.py b/mayan/apps/common/tests/mixins.py index 5838ba6fb2..41d386fd86 100644 --- a/mayan/apps/common/tests/mixins.py +++ b/mayan/apps/common/tests/mixins.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals import glob +import importlib import os import random @@ -255,15 +256,15 @@ class TestViewTestCaseMixin(object): has_test_view = False def tearDown(self): - from mayan.urls import urlpatterns + urlconf = importlib.import_module(settings.ROOT_URLCONF) self.client.logout() if self.has_test_view: - urlpatterns.pop(0) + urlconf.urlpatterns.pop(0) super(TestViewTestCaseMixin, self).tearDown() def add_test_view(self, test_object): - from mayan.urls import urlpatterns + urlconf = importlib.import_module(settings.ROOT_URLCONF) def test_view(request): template = Template('{{ object }}') @@ -272,7 +273,7 @@ class TestViewTestCaseMixin(object): ) return HttpResponse(template.render(context=context)) - urlpatterns.insert(0, url(TEST_VIEW_URL, test_view, name=TEST_VIEW_NAME)) + urlconf.urlpatterns.insert(0, url(TEST_VIEW_URL, test_view, name=TEST_VIEW_NAME)) clear_url_caches() self.has_test_view = True