Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/zeep/xsd/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _format(self, obj, stream, indent=4, level=1):
if num > 0:
for i, (key, value) in enumerate(obj.items()):
write(' ' * (indent * level))
write("'%s'" % key)
write('"%s"' % key)
write(': ')
self._format(value, stream, level=level + 1)
if i < num - 1:
Expand All @@ -53,7 +53,7 @@ def _format(self, obj, stream, indent=4, level=1):
write(' ' * (indent * (level - 1)))
write(']')
else:
value = repr(obj)
value = '%s' % obj
Copy link
Owner

@mvantellingen mvantellingen Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will return __str__ instead of __repr__. Is that correct?

if '\n' in value:
lines = value.split('\n')
num = len(lines)
Expand All @@ -64,4 +64,4 @@ def _format(self, obj, stream, indent=4, level=1):
if i < num - 1:
write('\n')
else:
write(value)
write('"%s"' % value)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are double quotes escaped properly here?

18 changes: 17 additions & 1 deletion tests/test_pprint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from zeep.xsd import printer


def test_dict():
pprint = printer.PrettyPrinter()
data = {
Expand Down Expand Up @@ -32,3 +32,19 @@ def test_list():
},
]
pprint.pformat(data)


def test_json_load():
pprint = printer.PrettyPrinter()
data = [
{
'foo': 'bar',
'foo_2': 'bar',
},
{
'foo': 'bar',
'foo_2': 'bar',
},
]
json.loads(pprint.pformat(data))