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
653d626b
Commit
653d626b
authored
Nov 25, 2014
by
José Padilla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix failing YAML tests
parent
e1b8412e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
tests/test_renderers.py
+4
-4
No files found.
tests/test_renderers.py
View file @
653d626b
...
@@ -9,7 +9,7 @@ from django.test import TestCase
...
@@ -9,7 +9,7 @@ from django.test import TestCase
from
django.utils
import
six
,
unittest
from
django.utils
import
six
,
unittest
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
rest_framework
import
status
,
permissions
from
rest_framework
import
status
,
permissions
from
rest_framework.compat
import
yaml
,
etree
,
StringIO
from
rest_framework.compat
import
yaml
,
etree
,
StringIO
,
BytesIO
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.views
import
APIView
from
rest_framework.views
import
APIView
from
rest_framework.renderers
import
BaseRenderer
,
JSONRenderer
,
YAMLRenderer
,
\
from
rest_framework.renderers
import
BaseRenderer
,
JSONRenderer
,
YAMLRenderer
,
\
...
@@ -467,7 +467,7 @@ if yaml:
...
@@ -467,7 +467,7 @@ if yaml:
obj
=
{
'foo'
:
[
'bar'
,
'baz'
]}
obj
=
{
'foo'
:
[
'bar'
,
'baz'
]}
renderer
=
YAMLRenderer
()
renderer
=
YAMLRenderer
()
content
=
renderer
.
render
(
obj
,
'application/yaml'
)
content
=
renderer
.
render
(
obj
,
'application/yaml'
)
self
.
assertEqual
(
content
,
_yaml_repr
)
self
.
assertEqual
(
content
.
decode
(
'utf-8'
)
,
_yaml_repr
)
def
test_render_and_parse
(
self
):
def
test_render_and_parse
(
self
):
"""
"""
...
@@ -480,7 +480,7 @@ if yaml:
...
@@ -480,7 +480,7 @@ if yaml:
parser
=
YAMLParser
()
parser
=
YAMLParser
()
content
=
renderer
.
render
(
obj
,
'application/yaml'
)
content
=
renderer
.
render
(
obj
,
'application/yaml'
)
data
=
parser
.
parse
(
String
IO
(
content
))
data
=
parser
.
parse
(
Bytes
IO
(
content
))
self
.
assertEqual
(
obj
,
data
)
self
.
assertEqual
(
obj
,
data
)
def
test_render_decimal
(
self
):
def
test_render_decimal
(
self
):
...
@@ -489,7 +489,7 @@ if yaml:
...
@@ -489,7 +489,7 @@ if yaml:
"""
"""
renderer
=
YAMLRenderer
()
renderer
=
YAMLRenderer
()
content
=
renderer
.
render
({
'field'
:
Decimal
(
'111.2'
)},
'application/yaml'
)
content
=
renderer
.
render
({
'field'
:
Decimal
(
'111.2'
)},
'application/yaml'
)
self
.
assertYAMLContains
(
content
,
"field: '111.2'"
)
self
.
assertYAMLContains
(
content
.
decode
(
'utf-8'
)
,
"field: '111.2'"
)
def
assertYAMLContains
(
self
,
content
,
string
):
def
assertYAMLContains
(
self
,
content
,
string
):
self
.
assertTrue
(
string
in
content
,
'
%
r not in
%
r'
%
(
string
,
content
))
self
.
assertTrue
(
string
in
content
,
'
%
r not in
%
r'
%
(
string
,
content
))
...
...
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