]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
Don't import the REST framework if it is disabled
authorDaniel Axtens <dja@axtens.net>
Tue, 9 Aug 2016 04:55:21 +0000 (14:55 +1000)
committerStephen Finucane <stephenfinucane@hotmail.com>
Sun, 21 Aug 2016 16:00:22 +0000 (17:00 +0100)
In the disabled case, also stub out the APITestCase class.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
patchwork/tests/test_rest_api.py

index 7ae7f272a45e57303e8e7c1b85bd4cd0c98d1489..0d8cc3fe3d8c11e06ae13b9e95aabe126e3d18c9 100644 (file)
@@ -22,8 +22,6 @@ import unittest
 
 from django.conf import settings
 from django.core.urlresolvers import reverse
-from rest_framework import status
-from rest_framework.test import APITestCase
 
 from patchwork.models import Check
 from patchwork.models import Patch
@@ -35,6 +33,13 @@ from patchwork.tests.utils import create_person
 from patchwork.tests.utils import create_project
 from patchwork.tests.utils import create_user
 
+if settings.ENABLE_REST_API:
+    from rest_framework import status
+    from rest_framework.test import APITestCase
+else:
+    # stub out APITestCase
+    from django.test import TestCase
+    APITestCase = TestCase
 
 @unittest.skipUnless(settings.ENABLE_REST_API, 'requires ENABLE_REST_API')
 class TestProjectAPI(APITestCase):