[PATCH 3/7] Don't import the REST framework if it is disabled
Daniel Axtens
dja at axtens.net
Tue Aug 9 14:55:21 AEST 2016
In the disabled case, also mock out the APITestCase class.
Signed-off-by: Daniel Axtens <dja at axtens.net>
---
patchwork/tests/test_rest_api.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
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):
--
2.7.4
More information about the Patchwork
mailing list