Merge "Remove extra white spaces in json output"

This commit is contained in:
Jenkins 2017-01-25 13:42:28 +00:00 committed by Gerrit Code Review
commit 65ba060592
2 changed files with 8 additions and 4 deletions

View File

@ -83,12 +83,14 @@ class TraceCommands(BaseCommand):
if args.use_json:
output = json.dumps(trace, default=datetime_json_serialize,
separators=(",", ": "),
indent=2)
elif args.use_html:
with open(os.path.join(os.path.dirname(__file__),
"template.html")) as html_template:
output = html_template.read().replace(
"$DATA", json.dumps(trace, indent=4,
separators=(",", ": "),
default=datetime_json_serialize))
elif args.use_dot:
dot_graph = self._create_dot_graph(trace)

View File

@ -199,7 +199,8 @@ class ShellTestCase(test.TestCase):
mock_get.return_value = notifications
self.run_command(self._trace_show_cmd(format_="json"))
self.assertEqual("%s\n" % json.dumps(notifications, indent=2),
self.assertEqual("%s\n" % json.dumps(notifications, indent=2,
separators=(",", ": "),),
sys.stdout.getvalue())
@mock.patch("sys.stdout", six.StringIO())
@ -227,7 +228,8 @@ class ShellTestCase(test.TestCase):
"spaceships, striking from a hidden"
"base, have won their first victory"
"against the evil Galactic Empire."
"\n" % json.dumps(notifications, indent=4),
"\n" % json.dumps(notifications, indent=4,
separators=(",", ": ")),
sys.stdout.getvalue())
@mock.patch("sys.stdout", six.StringIO())
@ -242,5 +244,5 @@ class ShellTestCase(test.TestCase):
self._trace_show_cmd(format_="json"))
output = mock_open.return_value.__enter__.return_value
output.write.assert_called_once_with(json.dumps(notifications,
indent=2))
output.write.assert_called_once_with(
json.dumps(notifications, indent=2, separators=(",", ": ")))