From 31e3eeb5e3d2d0b06416ad90d699de51d8761eda Mon Sep 17 00:00:00 2001 From: Zhiju Fan Date: Wed, 9 Jan 2019 10:31:32 +0800 Subject: [PATCH] BaseTools:TestTools character encoding issue Specifies encoding when opening a file using codecs Cc: Bob Feng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan Tested-by: Laszlo Ersek Tested-by: Ard Biesheuvel Reviewed-by: Liming Gao Reviewed-by: Bob Feng --- BaseTools/Tests/TestTools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py index 4332dcdaac..ace92992fc 100644 --- a/BaseTools/Tests/TestTools.py +++ b/BaseTools/Tests/TestTools.py @@ -24,6 +24,7 @@ import shutil import subprocess import sys import unittest +import codecs TestsDir = os.path.realpath(os.path.split(sys.argv[0])[0]) BaseToolsDir = os.path.realpath(os.path.join(TestsDir, '..')) @@ -150,7 +151,7 @@ class BaseToolsTest(unittest.TestCase): with open(self.GetTmpFilePath(fileName), 'wb') as f: f.write(data) else: - with open(self.GetTmpFilePath(fileName), 'w') as f: + with codecs.open(self.GetTmpFilePath(fileName), 'w', encoding='utf-8') as f: f.write(data) def GenRandomFileData(self, fileName, minlen = None, maxlen = None):