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
ef383d96
Commit
ef383d96
authored
May 18, 2013
by
Ryan Kaskel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up test case.
parent
22874e44
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
rest_framework/tests/serializer.py
+7
-7
No files found.
rest_framework/tests/serializer.py
View file @
ef383d96
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
django.db
import
models
from
django.db
import
models
from
django.db.models.fields
import
BLANK_CHOICE_DASH
from
django.db.models.fields
import
BLANK_CHOICE_DASH
from
django.utils.datastructures
import
MultiValueDict
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.utils.datastructures
import
MultiValueDict
from
django.utils.translation
import
ugettext_lazy
as
_
from
rest_framework
import
serializers
from
rest_framework
import
serializers
from
rest_framework.tests.models
import
(
HasPositiveIntegerAsChoice
,
Album
,
ActionItem
,
Anchor
,
BasicModel
,
from
rest_framework.tests.models
import
(
HasPositiveIntegerAsChoice
,
Album
,
ActionItem
,
Anchor
,
BasicModel
,
BlankFieldModel
,
BlogPost
,
BlogPostComment
,
Book
,
CallableDefaultValueModel
,
DefaultValueModel
,
BlankFieldModel
,
BlogPost
,
BlogPostComment
,
Book
,
CallableDefaultValueModel
,
DefaultValueModel
,
...
@@ -1246,6 +1247,7 @@ class DeserializeListTestCase(TestCase):
...
@@ -1246,6 +1247,7 @@ class DeserializeListTestCase(TestCase):
# test for issue 747
# test for issue 747
class
LazyStringModel
(
object
):
class
LazyStringModel
(
object
):
def
__init__
(
self
,
lazystring
):
def
__init__
(
self
,
lazystring
):
self
.
lazystring
=
lazystring
self
.
lazystring
=
lazystring
...
@@ -1258,16 +1260,14 @@ class LazyStringSerializer(serializers.Serializer):
...
@@ -1258,16 +1260,14 @@ class LazyStringSerializer(serializers.Serializer):
if
instance
is
not
None
:
if
instance
is
not
None
:
instance
.
lazystring
=
attrs
.
get
(
'lazystring'
,
instance
.
lazystring
)
instance
.
lazystring
=
attrs
.
get
(
'lazystring'
,
instance
.
lazystring
)
return
instance
return
instance
return
Comment
(
**
attrs
)
return
LazyStringModel
(
**
attrs
)
class
LazyStringsTestCase
(
TestCase
):
class
LazyStringsTestCase
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
from
django.utils.translation
import
ugettext_lazy
as
_
self
.
model
=
LazyStringModel
(
lazystring
=
_
(
'lazystring'
))
self
.
model
=
LazyStringModel
(
lazystring
=
_
(
"lazystring"
))
def
test_lazy_strings_are_translated
(
self
):
def
test_lazy_strings_are_translated
(
self
):
serializer
=
LazyStringSerializer
(
self
.
model
)
serializer
=
LazyStringSerializer
(
self
.
model
)
self
.
assertEqual
(
type
(
serializer
.
data
[
'lazystring'
]),
type
(
"lazystring"
))
self
.
assertEqual
(
type
(
serializer
.
data
[
'lazystring'
]),
type
(
'lazystring'
))
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