Remove extra white spaces in json output
json.dumps adds one space after colon by default. However, if we work with large trace, this will increase file size a lot. TrivialFix Change-Id: I46241ead0a09db4a32281f65a86bde2a413655b4
This commit is contained in:
parent
93aec6a99f
commit
3b51b0fb75
|
@ -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)
|
||||
|
|
|
@ -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=(",", ": ")))
|
||||
|
|
Loading…
Reference in New Issue