test: Fix char encoding issues on windows

Some tests were failing due to Windows not using utf-8
by default when executing the tests. Enforcing usage of utf-8
resolves these issues.

Signed-off-by: Daniel Kutik <daniel.kutik@lavawerk.com>
Change-Id: If42f6be2a2b688a6105ecf4fcdb541aade24519a
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/353179
Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Daniel Kutik 2022-11-27 13:31:48 +01:00
parent 0297f8312c
commit 003684b6e5

View File

@ -117,7 +117,7 @@ class ManifestParseTestCase(unittest.TestCase):
def getXmlManifest(self, data): def getXmlManifest(self, data):
"""Helper to initialize a manifest for testing.""" """Helper to initialize a manifest for testing."""
with open(self.manifest_file, 'w') as fp: with open(self.manifest_file, 'w', encoding="utf-8") as fp:
fp.write(data) fp.write(data)
return manifest_xml.XmlManifest(self.repodir, self.manifest_file) return manifest_xml.XmlManifest(self.repodir, self.manifest_file)
@ -428,7 +428,7 @@ class IncludeElementTests(ManifestParseTestCase):
def parse(name): def parse(name):
name = self.encodeXmlAttr(name) name = self.encodeXmlAttr(name)
# Setup target of the include. # Setup target of the include.
with open(os.path.join(self.manifest_dir, 'target.xml'), 'w') as fp: with open(os.path.join(self.manifest_dir, 'target.xml'), 'w', encoding="utf-8") as fp:
fp.write(f'<manifest><include name="{name}"/></manifest>') fp.write(f'<manifest><include name="{name}"/></manifest>')
manifest = self.getXmlManifest(""" manifest = self.getXmlManifest("""