Sort 'pbr freeze' output
Case-insensitive sort of pbr freeze output to make the output friendly to human eyes. Change-Id: I314082b5c7890e3cd4a99697fc2b1868dfedbb0f
This commit is contained in:
parent
b4d21581e2
commit
5b046f44b2
@ -68,7 +68,9 @@ def _get_info(name):
|
||||
|
||||
|
||||
def freeze(args):
|
||||
for dist in pkg_resources.working_set:
|
||||
sorted_dists = sorted(pkg_resources.working_set,
|
||||
key=lambda dist: dist.project_name.lower())
|
||||
for dist in sorted_dists:
|
||||
info = _get_info(dist.project_name)
|
||||
output = "{name}=={version}".format(**info)
|
||||
if info['sha']:
|
||||
|
@ -128,6 +128,9 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase):
|
||||
k.startswith('pbr_testpackage.')):
|
||||
del sys.modules[k]
|
||||
|
||||
def run_pbr(self, *args, **kwargs):
|
||||
return self._run_cmd('pbr', args, **kwargs)
|
||||
|
||||
def run_setup(self, *args, **kwargs):
|
||||
return self._run_cmd(sys.executable, ('setup.py',) + args, **kwargs)
|
||||
|
||||
|
@ -64,3 +64,13 @@ class TestCommands(base.BaseTestCase):
|
||||
self.addDetail('stderr', content.text_content(stderr))
|
||||
self.assertIn('Extracting rpm version', stdout)
|
||||
self.assertEqual(return_code, 0)
|
||||
|
||||
def test_freeze_command(self):
|
||||
"""Test that freeze output is sorted in a case-insensitive manner."""
|
||||
stdout, stderr, return_code = self.run_pbr('freeze')
|
||||
self.assertEqual(return_code, 0)
|
||||
pkgs = []
|
||||
for l in stdout.split('\n'):
|
||||
pkgs.append(l.split('==')[0].lower())
|
||||
pkgs_sort = sorted(pkgs[:])
|
||||
self.assertEqual(pkgs_sort, pkgs)
|
||||
|
Loading…
Reference in New Issue
Block a user