diff options
author | Liming Gao <liming.gao@intel.com> | 2018-10-15 08:27:53 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2018-10-15 08:29:14 +0800 |
commit | 1ccc4d895dd8d659d016efcd6ef8a48749aba1d0 (patch) | |
tree | 0d5f58643cc72275887d3bb322813609906a9334 /BaseTools/Tests | |
parent | 678f85131238622e576705117e299d81cff755c9 (diff) | |
download | edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.zip edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.tar.gz edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.tar.bz2 |
Revert BaseTools: PYTHON3 migration
This reverts commit 6693f359b3c213513c5096a06c6f67244a44dc52..
678f85131238622e576705117e299d81cff755c9.
Python3 migration is the fundamental change. It requires every developer
to install Python3. Before this migration, the well communication and wide
verification must be done. But now, most people is not aware of this change,
and not try it. So, Python3 migration is reverted and be moved to edk2-staging
Python3 branch for the edk2 user evaluation.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Tests')
-rw-r--r-- | BaseTools/Tests/CheckUnicodeSourceFiles.py | 6 | ||||
-rw-r--r-- | BaseTools/Tests/GNUmakefile | 2 | ||||
-rw-r--r-- | BaseTools/Tests/TestTools.py | 14 |
3 files changed, 10 insertions, 12 deletions
diff --git a/BaseTools/Tests/CheckUnicodeSourceFiles.py b/BaseTools/Tests/CheckUnicodeSourceFiles.py index c76b2bc..6ae62f1 100644 --- a/BaseTools/Tests/CheckUnicodeSourceFiles.py +++ b/BaseTools/Tests/CheckUnicodeSourceFiles.py @@ -110,7 +110,7 @@ class Tests(TestTools.BaseToolsTest): # This test makes sure that BaseTools rejects these characters
# if seen in a .uni file.
#
- data = codecs.BOM_UTF16_LE + b'//\x01\xd8 '
+ data = codecs.BOM_UTF16_LE + '//\x01\xd8 '
self.CheckFile(encoding=None, shouldPass=False, string=data)
@@ -161,7 +161,7 @@ class Tests(TestTools.BaseToolsTest): # This test makes sure that BaseTools rejects these characters
# if seen in a .uni file.
#
- data = b'\xed\xa0\x81'
+ data = '\xed\xa0\x81'
self.CheckFile(encoding=None, shouldPass=False, string=data)
@@ -170,7 +170,7 @@ class Tests(TestTools.BaseToolsTest): # Same test as testSurrogatePairUnicodeCharInUtf8File, but add
# the UTF-8 BOM
#
- data = codecs.BOM_UTF8 + b'\xed\xa0\x81'
+ data = codecs.BOM_UTF8 + '\xed\xa0\x81'
self.CheckFile(encoding=None, shouldPass=False, string=data)
diff --git a/BaseTools/Tests/GNUmakefile b/BaseTools/Tests/GNUmakefile index b920044..0c11f6a 100644 --- a/BaseTools/Tests/GNUmakefile +++ b/BaseTools/Tests/GNUmakefile @@ -14,7 +14,7 @@ all: test
test:
- @if command -v python3 >/dev/null 2>&1; then python3 RunTests.py; else echo "Error: Please install a python 3 tool!"; fi
+ @if command -v python2 >/dev/null 2>&1; then python2 RunTests.py; else python RunTests.py; fi
clean:
find . -name '*.pyc' -exec rm '{}' ';'
diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py index 65948a7..e16e993 100644 --- a/BaseTools/Tests/TestTools.py +++ b/BaseTools/Tests/TestTools.py @@ -40,7 +40,7 @@ if PythonSourceDir not in sys.path: def MakeTheTestSuite(localItems):
tests = []
- for name, item in localItems.items():
+ for name, item in localItems.iteritems():
if isinstance(item, type):
if issubclass(item, unittest.TestCase):
tests.append(unittest.TestLoader().loadTestsFromTestCase(item))
@@ -146,12 +146,9 @@ class BaseToolsTest(unittest.TestCase): return data
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:
- f.write(data)
+ f = open(self.GetTmpFilePath(fileName), 'w')
+ f.write(data)
+ f.close()
def GenRandomFileData(self, fileName, minlen = None, maxlen = None):
if maxlen is None: maxlen = minlen
@@ -164,7 +161,7 @@ class BaseToolsTest(unittest.TestCase): if maxlen is None: maxlen = minlen
return ''.join(
[chr(random.randint(0, 255))
- for x in range(random.randint(minlen, maxlen))
+ for x in xrange(random.randint(minlen, maxlen))
])
def setUp(self):
@@ -186,3 +183,4 @@ class BaseToolsTest(unittest.TestCase): os.environ['PATH'] = self.savedEnvPath
sys.path = self.savedSysPath
+
|