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
b3e01452
Commit
b3e01452
authored
Oct 17, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1181 from badale/master
Fixed #1179: RepresenterError with DecimalField and YAMLRenderer
parents
bdf8b532
b730aec0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletions
+15
-1
rest_framework/tests/test_renderers.py
+12
-1
rest_framework/utils/encoders.py
+3
-0
No files found.
rest_framework/tests/test_renderers.py
View file @
b3e01452
...
...
@@ -328,7 +328,7 @@ if yaml:
class
YAMLRendererTests
(
TestCase
):
"""
Tests specific to the
JSON
Renderer
Tests specific to the
YAML
Renderer
"""
def
test_render
(
self
):
...
...
@@ -354,6 +354,17 @@ if yaml:
data
=
parser
.
parse
(
StringIO
(
content
))
self
.
assertEqual
(
obj
,
data
)
def
test_render_decimal
(
self
):
"""
Test YAML decimal rendering.
"""
renderer
=
YAMLRenderer
()
content
=
renderer
.
render
({
'field'
:
Decimal
(
'111.2'
)},
'application/yaml'
)
self
.
assertYAMLContains
(
content
,
"field: '111.2'"
)
def
assertYAMLContains
(
self
,
content
,
string
):
self
.
assertTrue
(
string
in
content
,
'
%
r not in
%
r'
%
(
string
,
content
))
class
XMLRendererTestCase
(
TestCase
):
"""
...
...
rest_framework/utils/encoders.py
View file @
b3e01452
...
...
@@ -89,6 +89,9 @@ else:
node
.
flow_style
=
best_style
return
node
SafeDumper
.
add_representer
(
decimal
.
Decimal
,
SafeDumper
.
represent_decimal
)
SafeDumper
.
add_representer
(
SortedDict
,
yaml
.
representer
.
SafeRepresenter
.
represent_dict
)
SafeDumper
.
add_representer
(
DictWithMetadata
,
...
...
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