diff mbox

[3/7] Don't import the REST framework if it is disabled

Message ID 1470718525-32603-4-git-send-email-dja@axtens.net
State Accepted
Headers show

Commit Message

Daniel Axtens Aug. 9, 2016, 4:55 a.m. UTC
In the disabled case, also mock out the APITestCase class.

Signed-off-by: Daniel Axtens <dja@axtens.net>
---
 patchwork/tests/test_rest_api.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Stephen Finucane Aug. 21, 2016, 1:41 p.m. UTC | #1
On 09 Aug 14:55, Daniel Axtens wrote:
> In the disabled case, also mock out the APITestCase class.
> 
> Signed-off-by: Daniel Axtens <dja@axtens.net>

Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
diff mbox

Patch

diff --git a/patchwork/tests/test_rest_api.py b/patchwork/tests/test_rest_api.py
index 7ae7f272a45e..a2199d8afe29 100644
--- a/patchwork/tests/test_rest_api.py
+++ b/patchwork/tests/test_rest_api.py
@@ -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:
+    # mock out APITestCase
+    from django.test import TestCase
+    APITestCase = TestCase
 
 @unittest.skipUnless(settings.ENABLE_REST_API, 'requires ENABLE_REST_API')
 class TestProjectAPI(APITestCase):