Browse Source

Merge "kolla-build --list-dependencies use json, not pprint"

tags/5.0.0.0b3
Jenkins 1 year ago
parent
commit
49e45698da
2 changed files with 5 additions and 5 deletions
  1. 1
    2
      kolla/image/build.py
  2. 4
    3
      kolla/tests/test_build.py

+ 1
- 2
kolla/image/build.py View File

@@ -20,7 +20,6 @@ import errno
20 20
 import json
21 21
 import logging
22 22
 import os
23
-import pprint
24 23
 import re
25 24
 import requests
26 25
 import shutil
@@ -1025,7 +1024,7 @@ class KollaWorker(object):
1025 1024
 
1026 1025
         ancestry = {base.name: []}
1027 1026
         list_children(base.children, ancestry)
1028
-        pprint.pprint(ancestry)
1027
+        json.dump(ancestry, sys.stdout, indent=2)
1029 1028
 
1030 1029
     def find_parents(self):
1031 1030
         """Associate all images with parents and children."""

+ 4
- 3
kolla/tests/test_build.py View File

@@ -15,6 +15,7 @@ import itertools
15 15
 import mock
16 16
 import os
17 17
 import requests
18
+import sys
18 19
 
19 20
 from kolla.cmd import build as build_cmd
20 21
 from kolla import exception
@@ -352,14 +353,14 @@ class KollaWorkerTest(base.TestCase):
352 353
         self.assertRaises(ValueError,
353 354
                           kolla.filter_images)
354 355
 
355
-    @mock.patch('pprint.pprint')
356
-    def test_list_dependencies(self, pprint_mock):
356
+    @mock.patch('json.dump')
357
+    def test_list_dependencies(self, dump_mock):
357 358
         self.conf.set_override('profile', ['all'])
358 359
         kolla = build.KollaWorker(self.conf)
359 360
         kolla.images = self.images
360 361
         kolla.filter_images()
361 362
         kolla.list_dependencies()
362
-        pprint_mock.assert_called_once_with(mock.ANY)
363
+        dump_mock.assert_called_once_with(mock.ANY, sys.stdout, indent=2)
363 364
 
364 365
     def test_summary(self):
365 366
         kolla = build.KollaWorker(self.conf)

Loading…
Cancel
Save