diff options
| author | Pierre Dulac | 2013-03-03 01:09:39 +0100 |
|---|---|---|
| committer | Pierre Dulac | 2013-03-06 22:42:09 +0100 |
| commit | 8845c0be88bf68fa0e42d05c7196cd52d897623b (patch) | |
| tree | 820a7e5ad1f3de55e4862f091b421c67692a6de2 | |
| parent | 30e3775b8b209242141357bad0a69b6cc503c6f9 (diff) | |
| download | django-rest-framework-8845c0be88bf68fa0e42d05c7196cd52d897623b.tar.bz2 | |
Fix import errors
| -rw-r--r-- | rest_framework/compat.py | 7 | ||||
| -rw-r--r-- | rest_framework/runtests/settings.py | 2 | ||||
| -rw-r--r-- | rest_framework/tests/authentication.py | 8 |
3 files changed, 14 insertions, 3 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py index e0a43f3f..1e04e8f6 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -431,5 +431,12 @@ except ImportError: # OAuth 2 support is optional try: 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: oauth2_provider = None diff --git a/rest_framework/runtests/settings.py b/rest_framework/runtests/settings.py index b1501cf3..16ef1d2b 100644 --- a/rest_framework/runtests/settings.py +++ b/rest_framework/runtests/settings.py @@ -106,7 +106,7 @@ try: 'provider', 'provider.oauth2', ) -except ImportError, inst: +except ImportError: import logging logging.warning("django-oauth2-provider is not install, some tests will be skipped") diff --git a/rest_framework/tests/authentication.py b/rest_framework/tests/authentication.py index 9d67a005..a02aef55 100644 --- a/rest_framework/tests/authentication.py +++ b/rest_framework/tests/authentication.py @@ -46,10 +46,14 @@ urlpatterns = patterns('', (r'^basic/$', MockView.as_view(authentication_classes=[BasicAuthentication])), (r'^token/$', MockView.as_view(authentication_classes=[TokenAuthentication])), (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): """Basic authentication""" |
