mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Changed error to warning message
This commit is contained in:
parent
fbd89d6b7e
commit
dab6bf4b1a
|
@ -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
|
||||
back to the defaults.
|
||||
"""
|
||||
import warnings
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
|
@ -216,7 +217,7 @@ class APISettings(object):
|
|||
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
|
||||
|
||||
|
||||
|
|
|
@ -18,15 +18,18 @@ class TestSettings(TestCase):
|
|||
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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user