Commit dab6bf4b by Luis San Pablo

Changed error to warning message

parent fbd89d6b
...@@ -17,6 +17,7 @@ This module provides the `api_setting` object, that is used to access ...@@ -17,6 +17,7 @@ This module provides the `api_setting` object, that is used to access
REST framework settings, checking for user settings first, then falling REST framework settings, checking for user settings first, then falling
back to the defaults. back to the defaults.
""" """
import warnings
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings from django.conf import settings
...@@ -216,7 +217,7 @@ class APISettings(object): ...@@ -216,7 +217,7 @@ class APISettings(object):
SETTINGS_DOC = "http://www.django-rest-framework.org/api-guide/settings/" SETTINGS_DOC = "http://www.django-rest-framework.org/api-guide/settings/"
for setting in REMOVED_SETTINGS: for setting in REMOVED_SETTINGS:
if setting in user_settings: if setting in user_settings:
raise AttributeError("The '%s' setting has been removed. Please refer to '%s' for available settings." % (setting, SETTINGS_DOC)) warnings.warn("The '%s' setting has been removed. Please refer to '%s' for available settings." % (setting, SETTINGS_DOC), DeprecationWarning)
return user_settings return user_settings
......
...@@ -18,15 +18,18 @@ class TestSettings(TestCase): ...@@ -18,15 +18,18 @@ class TestSettings(TestCase):
with self.assertRaises(ImportError): with self.assertRaises(ImportError):
settings.DEFAULT_RENDERER_CLASSES settings.DEFAULT_RENDERER_CLASSES
def test_loud_error_raised_on_removed_setting(self): def test_warning_raised_on_removed_setting(self):
""" """
Make sure user is alerted with an error when a removed setting Make sure user is alerted with an error when a removed setting
is set. is set.
""" """
with self.assertRaises(AttributeError): with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
APISettings({ APISettings({
'MAX_PAGINATE_BY': 100 'MAX_PAGINATE_BY': 100
}) })
self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
class TestSettingTypes(TestCase): class TestSettingTypes(TestCase):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment