From 5d58c18146e1cda1ab9a3593fd1324985bb5d638 Mon Sep 17 00:00:00 2001 From: Peter Kjellerstedt Date: Mon, 12 Apr 2021 21:16:36 +0200 Subject: 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 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/303326 Reviewed-by: Mike Frysinger --- tests/test_git_superproject.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'tests/test_git_superproject.py') 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 import git_superproject import manifest_xml import platform_utils +from test_manifest_xml import sort_attributes class SuperprojectTestCase(unittest.TestCase): @@ -140,12 +141,12 @@ class SuperprojectTestCase(unittest.TestCase): with open(manifest_path, 'r') as fp: manifest_xml = fp.read() self.assertEqual( - manifest_xml, + sort_attributes(manifest_xml), '' - '' + '' '' - '' + '' '' '') @@ -167,13 +168,13 @@ class SuperprojectTestCase(unittest.TestCase): with open(manifest_path, 'r') as fp: manifest_xml = fp.read() self.assertEqual( - manifest_xml, + sort_attributes(manifest_xml), '' - '' + '' '' - '' + '' '' '') @@ -208,16 +209,17 @@ class SuperprojectTestCase(unittest.TestCase): with open(manifest_path, 'r') as fp: manifest_xml = fp.read() self.assertEqual( - manifest_xml, + sort_attributes(manifest_xml), '' - '' - '' + '' + '' '' - '' - '' + '' + '' '' '') -- cgit v1.2.3-54-g00ecf