summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-11-28 20:17:33 +0000
committerGerrit Code Review <review@openstack.org>2016-11-28 20:17:33 +0000
commit42e3c76ebc33aa61744ab593e2be0fce47ff7c34 (patch)
tree22fd66a969ccf6a4a74f85360321577a0eccc306
parentbdd7d75f73d2184db013e66a0696b606468a0666 (diff)
parent80b28562eddb22c1add9ac950e689ee7bc586d93 (diff)
downloadosprofiler-42e3c76ebc33aa61744ab593e2be0fce47ff7c34.tar.gz
Merge "Pretty print json output"
-rw-r--r--osprofiler/cmd/commands.py3
-rw-r--r--osprofiler/tests/cmd/test_shell.py5
2 files changed, 5 insertions, 3 deletions
diff --git a/osprofiler/cmd/commands.py b/osprofiler/cmd/commands.py
index 99be83e..876493b 100644
--- a/osprofiler/cmd/commands.py
+++ b/osprofiler/cmd/commands.py
@@ -76,7 +76,8 @@ class TraceCommands(BaseCommand):
return obj
if args.use_json:
- output = json.dumps(trace, default=datetime_json_serialize)
+ output = json.dumps(trace, default=datetime_json_serialize,
+ indent=2)
elif args.use_html:
with open(os.path.join(os.path.dirname(__file__),
"template.html")) as html_template:
diff --git a/osprofiler/tests/cmd/test_shell.py b/osprofiler/tests/cmd/test_shell.py
index fa79c27..fc573ed 100644
--- a/osprofiler/tests/cmd/test_shell.py
+++ b/osprofiler/tests/cmd/test_shell.py
@@ -174,7 +174,7 @@ class ShellTestCase(test.TestCase):
mock_get.return_value = notifications
self.run_command("trace show fake_id --json")
- self.assertEqual("%s\n" % json.dumps(notifications),
+ self.assertEqual("%s\n" % json.dumps(notifications, indent=2),
sys.stdout.getvalue())
@mock.patch("sys.stdout", six.StringIO())
@@ -222,4 +222,5 @@ class ShellTestCase(test.TestCase):
self.run_command("trace show fake_id --json --out='/file'")
output = mock_open.return_value.__enter__.return_value
- output.write.assert_called_once_with(json.dumps(notifications))
+ output.write.assert_called_once_with(json.dumps(notifications,
+ indent=2))