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
7cfa0e03
Commit
7cfa0e03
authored
Dec 16, 2014
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge lateset version-3.1
parents
6e51e4f5
74483338
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
20 deletions
+13
-20
rest_framework/settings.py
+2
-3
tests/extras/__init__.py
+0
-0
tests/extras/bad_import.py
+0
-1
tests/test_settings.py
+11
-16
No files found.
rest_framework/settings.py
View file @
7cfa0e03
...
@@ -49,7 +49,6 @@ DEFAULTS = {
...
@@ -49,7 +49,6 @@ DEFAULTS = {
'DEFAULT_VERSIONING_CLASS'
:
None
,
'DEFAULT_VERSIONING_CLASS'
:
None
,
# Generic view behavior
# Generic view behavior
'DEFAULT_MODEL_SERIALIZER_CLASS'
:
'rest_framework.serializers.ModelSerializer'
,
'DEFAULT_PAGINATION_SERIALIZER_CLASS'
:
'rest_framework.pagination.PaginationSerializer'
,
'DEFAULT_PAGINATION_SERIALIZER_CLASS'
:
'rest_framework.pagination.PaginationSerializer'
,
'DEFAULT_FILTER_BACKENDS'
:
(),
'DEFAULT_FILTER_BACKENDS'
:
(),
...
@@ -179,8 +178,8 @@ class APISettings(object):
...
@@ -179,8 +178,8 @@ class APISettings(object):
"""
"""
def
__init__
(
self
,
user_settings
=
None
,
defaults
=
None
,
import_strings
=
None
):
def
__init__
(
self
,
user_settings
=
None
,
defaults
=
None
,
import_strings
=
None
):
self
.
user_settings
=
user_settings
or
{}
self
.
user_settings
=
user_settings
or
{}
self
.
defaults
=
defaults
or
{}
self
.
defaults
=
defaults
or
DEFAULTS
self
.
import_strings
=
import_strings
or
()
self
.
import_strings
=
import_strings
or
IMPORT_STRINGS
def
__getattr__
(
self
,
attr
):
def
__getattr__
(
self
,
attr
):
if
attr
not
in
self
.
defaults
.
keys
():
if
attr
not
in
self
.
defaults
.
keys
():
...
...
tests/extras/__init__.py
deleted
100644 → 0
View file @
6e51e4f5
tests/extras/bad_import.py
deleted
100644 → 0
View file @
6e51e4f5
raise
ValueError
tests/test_settings.py
View file @
7cfa0e03
"""Tests for the settings module"""
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
django.test
import
TestCase
from
rest_framework.settings
import
APISettings
from
rest_framework.settings
import
APISettings
,
DEFAULTS
,
IMPORT_STRINGS
class
TestSettings
(
TestCase
):
class
TestSettings
(
TestCase
):
"""Tests relating to the api settings"""
def
test_non_import_errors
(
self
):
"""Make sure other errors aren't suppressed."""
settings
=
APISettings
({
'DEFAULT_MODEL_SERIALIZER_CLASS'
:
'tests.extras.bad_import.ModelSerializer'
},
DEFAULTS
,
IMPORT_STRINGS
)
with
self
.
assertRaises
(
ValueError
):
settings
.
DEFAULT_MODEL_SERIALIZER_CLASS
def
test_import_error_message_maintained
(
self
):
def
test_import_error_message_maintained
(
self
):
"""Make sure real import errors are captured and raised sensibly."""
"""
settings
=
APISettings
({
'DEFAULT_MODEL_SERIALIZER_CLASS'
:
'tests.extras.not_here.ModelSerializer'
},
DEFAULTS
,
IMPORT_STRINGS
)
Make sure import errors are captured and raised sensibly.
with
self
.
assertRaises
(
ImportError
)
as
cm
:
"""
settings
.
DEFAULT_MODEL_SERIALIZER_CLASS
settings
=
APISettings
({
self
.
assertTrue
(
'ImportError'
in
str
(
cm
.
exception
))
'DEFAULT_RENDERER_CLASSES'
:
[
'tests.invalid_module.InvalidClassName'
]
})
with
self
.
assertRaises
(
ImportError
):
settings
.
DEFAULT_RENDERER_CLASSES
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