From 9983229eb6b96f40ca66087132077e6887e8721b Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Tue, 9 Aug 2016 14:55:21 +1000 Subject: [PATCH] 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 --- 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 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): -- 2.47.3