From: Daniel Axtens Date: Tue, 9 Aug 2016 04:55:21 +0000 (+1000) Subject: Don't import the REST framework if it is disabled X-Git-Tag: v2.0.0-rc1~284 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9983229eb6b96f40ca66087132077e6887e8721b;p=thirdparty%2Fpatchwork.git Don't import the REST framework if it is disabled In the disabled case, also stub out the APITestCase class. Signed-off-by: Daniel Axtens Reviewed-by: Stephen Finucane --- diff --git a/patchwork/tests/test_rest_api.py b/patchwork/tests/test_rest_api.py index 7ae7f272..0d8cc3fe 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: + # stub out APITestCase + from django.test import TestCase + APITestCase = TestCase @unittest.skipUnless(settings.ENABLE_REST_API, 'requires ENABLE_REST_API') class TestProjectAPI(APITestCase):