python/samba/netcmd: PY3 fix CI error for samba.tests.samba_tool.help
authorNoel Power <noel.power@suse.com>
Wed, 17 Oct 2018 17:06:34 +0000 (18:06 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 23 Oct 2018 03:50:29 +0000 (05:50 +0200)
Strangely the test was failing on CI only, looks like there is an
issue with order of elements returned from dict.items() with python3.4
(version of python in CI docker instance) and python3.6 (version on my
development machine). Changed code to sort the keys so order of help
printed out should be the same for each invocation.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/__init__.py

index 2b874d22d1f4dc5185ec363ed368dde1d5dafac4..57436c7a4412bef6c54ebea6022b24ae985914ab 100644 (file)
@@ -138,7 +138,8 @@ class Command(object):
             prog=prog, epilog=epilog)
         parser.add_options(self.takes_options)
         optiongroups = {}
-        for name, optiongroup in self.takes_optiongroups.items():
+        for name in sorted(self.takes_optiongroups.keys()):
+            optiongroup = self.takes_optiongroups[name]
             optiongroups[name] = optiongroup(parser)
             parser.add_option_group(optiongroups[name])
         return parser, optiongroups