python/samba/gp_parse: Fix test errors with python3.8
authorNoel Power <noel.power@suse.com>
Fri, 13 Mar 2020 17:32:20 +0000 (17:32 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 19 Mar 2020 20:46:42 +0000 (20:46 +0000)
UNEXPECTED(failure): samba.tests.samba_tool.gpo.samba.tests.samba_tool.gpo.GpoCmdTestCase.test_backup_restore_generalize(ad_dc:local)
REASON: Exception: Exception: Traceback (most recent call last):
  File "/tmp/samba-testbase/b28/samba-ad-dc-1/bin/python/samba/tests/samba_tool/gpo.py", line 434, in test_backup_restore_generalize
    self.assertIsNone(has_difference(os.path.join(new_path, 'policy',

This caused because prior to 3.8 minodom.toprettyxml() was sorting the
attribute order, now it preserves the attribute order specified by the user
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/gp_parse/gp_pol.py

index 67ecd584dc01a3e27e3843b373666b6c62c26138..8a3d5f58ec17569f60fadf61c8a67e58491fd86f 100644 (file)
@@ -101,9 +101,9 @@ class GPPolParser(GPParser):
     def write_xml(self, filename):
         with open(filename, 'wb') as f:
             root = Element('PolFile')
+            root.attrib['num_entries'] = str(self.pol_file.num_entries)
             root.attrib['signature'] = self.pol_file.header.signature
             root.attrib['version'] = str(self.pol_file.header.version)
-            root.attrib['num_entries'] = str(self.pol_file.num_entries)
             for entry in self.pol_file.entries:
                 child = SubElement(root, 'Entry')
                 # child.attrib['size'] = str(entry.size)