From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B2FFC211BA47C for ; Thu, 24 Jan 2019 21:05:08 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2019 21:05:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,519,1539673200"; d="scan'208";a="294272559" Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.47]) by orsmga005.jf.intel.com with ESMTP; 24 Jan 2019 21:05:07 -0800 From: "Feng, Bob C" To: edk2-devel@lists.01.org Cc: Zhiju Fan , Bob Feng , Liming Gao Date: Fri, 25 Jan 2019 12:56:11 +0800 Message-Id: <20190125045626.14700-19-bob.c.feng@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 In-Reply-To: <20190125045626.14700-1-bob.c.feng@intel.com> References: <20190125045626.14700-1-bob.c.feng@intel.com> MIME-Version: 1.0 Subject: [Patch 18/33] BaseTools:TestTools character encoding issue X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2019 05:05:08 -0000 Content-Transfer-Encoding: 8bit From: Zhiju Fan 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 --- 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 @@ -22,10 +22,11 @@ import os.path import random 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, '..')) CSourceDir = os.path.join(BaseToolsDir, 'Source', 'C') PythonSourceDir = os.path.join(BaseToolsDir, 'Source', 'Python') @@ -148,11 +149,11 @@ class BaseToolsTest(unittest.TestCase): def WriteTmpFile(self, fileName, data): if isinstance(data, bytes): 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): if maxlen is None: maxlen = minlen f = self.OpenTmpFile(fileName, 'w') -- 2.20.1.windows.1