mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Fix import errors
This commit is contained in:
parent
30e3775b8b
commit
8845c0be88
|
@ -431,5 +431,12 @@ except ImportError:
|
||||||
# OAuth 2 support is optional
|
# OAuth 2 support is optional
|
||||||
try:
|
try:
|
||||||
import provider.oauth2 as oauth2_provider
|
import provider.oauth2 as oauth2_provider
|
||||||
|
|
||||||
|
# Hack to fix submodule import issues
|
||||||
|
submodules = ['backends', 'forms','managers','models','urls','views']
|
||||||
|
for s in submodules:
|
||||||
|
mod = __import__('provider.oauth2.%s.*' % s)
|
||||||
|
setattr(oauth2_provider, s, mod)
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
oauth2_provider = None
|
oauth2_provider = None
|
||||||
|
|
|
@ -106,7 +106,7 @@ try:
|
||||||
'provider',
|
'provider',
|
||||||
'provider.oauth2',
|
'provider.oauth2',
|
||||||
)
|
)
|
||||||
except ImportError, inst:
|
except ImportError:
|
||||||
import logging
|
import logging
|
||||||
logging.warning("django-oauth2-provider is not install, some tests will be skipped")
|
logging.warning("django-oauth2-provider is not install, some tests will be skipped")
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,14 @@ urlpatterns = patterns('',
|
||||||
(r'^basic/$', MockView.as_view(authentication_classes=[BasicAuthentication])),
|
(r'^basic/$', MockView.as_view(authentication_classes=[BasicAuthentication])),
|
||||||
(r'^token/$', MockView.as_view(authentication_classes=[TokenAuthentication])),
|
(r'^token/$', MockView.as_view(authentication_classes=[TokenAuthentication])),
|
||||||
(r'^auth-token/$', 'rest_framework.authtoken.views.obtain_auth_token'),
|
(r'^auth-token/$', 'rest_framework.authtoken.views.obtain_auth_token'),
|
||||||
url(r'^oauth2/', include('provider.oauth2.urls', namespace = 'oauth2')),
|
|
||||||
url(r'^oauth2-test/$', MockView.as_view(authentication_classes=[OAuth2Authentication])),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if oauth2_provider is not None:
|
||||||
|
urlpatterns += patterns('',
|
||||||
|
url(r'^oauth2/', include('provider.oauth2.urls', namespace = 'oauth2')),
|
||||||
|
url(r'^oauth2-test/$', MockView.as_view(authentication_classes=[OAuth2Authentication])),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class BasicAuthTests(TestCase):
|
class BasicAuthTests(TestCase):
|
||||||
"""Basic authentication"""
|
"""Basic authentication"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user