Skip to content

Commit

Permalink
Changed error to warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
lsanpablo committed Dec 17, 2015
1 parent fbd89d6 commit dab6bf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion rest_framework/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
REST framework settings, checking for user settings first, then falling
back to the defaults.
"""
import warnings
from __future__ import unicode_literals

from django.conf import settings
Expand Down Expand Up @@ -216,7 +217,7 @@ def __check_user_settings(self, user_settings):
SETTINGS_DOC = "http://www.django-rest-framework.org/api-guide/settings/"
for setting in REMOVED_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


Expand Down
7 changes: 5 additions & 2 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ def test_import_error_message_maintained(self):
with self.assertRaises(ImportError):
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
is set.
"""
with self.assertRaises(AttributeError):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
APISettings({
'MAX_PAGINATE_BY': 100
})
self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[-1].category, DeprecationWarning))


class TestSettingTypes(TestCase):
Expand Down

0 comments on commit dab6bf4

Please sign in to comment.