-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathcompat.py
30 lines (23 loc) · 890 Bytes
/
compat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from django.test import TestCase as DjangoTestCase
try:
from django.urls import reverse, NoReverseMatch
except ImportError:
from django.core.urlresolvers import reverse, NoReverseMatch # noqa
try:
import rest_framework # noqa
DRF = True
except ImportError:
DRF = False
def get_api_client():
try:
from rest_framework.test import APIClient
except ImportError:
from django.core.exceptions import ImproperlyConfigured
def APIClient(*args, **kwargs):
raise ImproperlyConfigured('django-rest-framework must be installed in order to use APITestCase.')
return APIClient
if hasattr(DjangoTestCase, 'assertURLEqual'):
assertURLEqual = DjangoTestCase.assertURLEqual
else:
def assertURLEqual(t, url1, url2, msg_prefix=''):
raise NotImplementedError("Your version of Django does not support `assertURLEqual`")