Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
dab6bf4b
Commit
dab6bf4b
authored
Dec 16, 2015
by
Luis San Pablo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed error to warning message
parent
fbd89d6b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
rest_framework/settings.py
+2
-1
tests/test_settings.py
+5
-2
No files found.
rest_framework/settings.py
View file @
dab6bf4b
...
...
@@ -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
...
...
tests/test_settings.py
View file @
dab6bf4b
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment