summaryrefslogtreecommitdiffstats
path: root/tests/test_git_superproject.py
diff options
context:
space:
mode:
authorPeter Kjellerstedt <pkj@axis.com>2021-04-12 21:16:36 +0200
committerMike Frysinger <vapier@google.com>2021-05-26 13:36:20 +0000
commit5d58c18146e1cda1ab9a3593fd1324985bb5d638 (patch)
tree4aca227a0786ab20461857962bf48496986d0522 /tests/test_git_superproject.py
parentd177609cb0283e41e23d4c19b94e17f42bdbdacb (diff)
downloadgit-repo-5d58c18146e1cda1ab9a3593fd1324985bb5d638.tar.gz
tests: Make the tests pass for Python < 3.8
Before Python 3.8, xml.dom.minidom sorted the attributes of an element when writing it to a file, while later versions output the attributes in the order they were created. Avoid these differences by sorting the attributes for each element before comparing the generated manifests with the expected ones. Bug: https://crbug.com/gerrit/14382 Change-Id: Ie2597727afcc48f9063a7261ad970e8a549f0587 Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/303326 Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests/test_git_superproject.py')
-rw-r--r--tests/test_git_superproject.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py
index 5c1455f5..b1ae3576 100644
--- a/tests/test_git_superproject.py
+++ b/tests/test_git_superproject.py
@@ -23,6 +23,7 @@ from unittest import mock
23import git_superproject 23import git_superproject
24import manifest_xml 24import manifest_xml
25import platform_utils 25import platform_utils
26from test_manifest_xml import sort_attributes
26 27
27 28
28class SuperprojectTestCase(unittest.TestCase): 29class SuperprojectTestCase(unittest.TestCase):
@@ -140,12 +141,12 @@ class SuperprojectTestCase(unittest.TestCase):
140 with open(manifest_path, 'r') as fp: 141 with open(manifest_path, 'r') as fp:
141 manifest_xml = fp.read() 142 manifest_xml = fp.read()
142 self.assertEqual( 143 self.assertEqual(
143 manifest_xml, 144 sort_attributes(manifest_xml),
144 '<?xml version="1.0" ?><manifest>' 145 '<?xml version="1.0" ?><manifest>'
145 '<remote name="default-remote" fetch="http://localhost"/>' 146 '<remote fetch="http://localhost" name="default-remote"/>'
146 '<default remote="default-remote" revision="refs/heads/main"/>' 147 '<default remote="default-remote" revision="refs/heads/main"/>'
147 '<project name="platform/art" path="art" revision="ABCDEF" ' 148 '<project groups="notdefault,platform-' + self.platform + '" '
148 'groups="notdefault,platform-' + self.platform + '"/>' 149 'name="platform/art" path="art" revision="ABCDEF"/>'
149 '<superproject name="superproject"/>' 150 '<superproject name="superproject"/>'
150 '</manifest>') 151 '</manifest>')
151 152
@@ -167,13 +168,13 @@ class SuperprojectTestCase(unittest.TestCase):
167 with open(manifest_path, 'r') as fp: 168 with open(manifest_path, 'r') as fp:
168 manifest_xml = fp.read() 169 manifest_xml = fp.read()
169 self.assertEqual( 170 self.assertEqual(
170 manifest_xml, 171 sort_attributes(manifest_xml),
171 '<?xml version="1.0" ?><manifest>' 172 '<?xml version="1.0" ?><manifest>'
172 '<remote name="default-remote" fetch="http://localhost"/>' 173 '<remote fetch="http://localhost" name="default-remote"/>'
173 '<default remote="default-remote" revision="refs/heads/main"/>' 174 '<default remote="default-remote" revision="refs/heads/main"/>'
174 '<project name="platform/art" path="art" ' 175 '<project groups="notdefault,platform-' + self.platform + '" '
175 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea" ' 176 'name="platform/art" path="art" '
176 'groups="notdefault,platform-' + self.platform + '"/>' 177 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea"/>'
177 '<superproject name="superproject"/>' 178 '<superproject name="superproject"/>'
178 '</manifest>') 179 '</manifest>')
179 180
@@ -208,16 +209,17 @@ class SuperprojectTestCase(unittest.TestCase):
208 with open(manifest_path, 'r') as fp: 209 with open(manifest_path, 'r') as fp:
209 manifest_xml = fp.read() 210 manifest_xml = fp.read()
210 self.assertEqual( 211 self.assertEqual(
211 manifest_xml, 212 sort_attributes(manifest_xml),
212 '<?xml version="1.0" ?><manifest>' 213 '<?xml version="1.0" ?><manifest>'
213 '<remote name="default-remote" fetch="http://localhost"/>' 214 '<remote fetch="http://localhost" name="default-remote"/>'
214 '<remote name="goog" fetch="http://localhost2"/>' 215 '<remote fetch="http://localhost2" name="goog"/>'
215 '<default remote="default-remote" revision="refs/heads/main"/>' 216 '<default remote="default-remote" revision="refs/heads/main"/>'
216 '<project name="platform/art" path="art" ' 217 '<project groups="notdefault,platform-' + self.platform + '" '
217 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea" ' 218 'name="platform/art" path="art" '
218 'groups="notdefault,platform-' + self.platform + '"/>' 219 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea"/>'
219 '<project name="platform/vendor/x" path="vendor/x" remote="goog" ' 220 '<project clone-depth="1" groups="vendor" '
220 'revision="master-with-vendor" groups="vendor" clone-depth="1"/>' 221 'name="platform/vendor/x" path="vendor/x" remote="goog" '
222 'revision="master-with-vendor"/>'
221 '<superproject name="superproject"/>' 223 '<superproject name="superproject"/>'
222 '</manifest>') 224 '</manifest>')
223 225