X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FTests%2FTestTools.py;h=20a4ea28aa11b0622429cd222b932d94e92b146c;hb=aaa4c651bf5ba5fce14e9fe8c2c12687886f745d;hp=ac009db1fa66414e67f6dec18b84698e3c4cff9f;hpb=f51461c829c124288a930829a78e2a5a799f4039;p=mirror_edk2.git
diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py
index ac009db1fa..20a4ea28aa 100644
--- a/BaseTools/Tests/TestTools.py
+++ b/BaseTools/Tests/TestTools.py
@@ -1,7 +1,8 @@
+from __future__ import print_function
## @file
# Utility functions and classes for BaseTools unit tests
#
-# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -22,7 +23,6 @@ import random
import shutil
import subprocess
import sys
-import types
import unittest
TestsDir = os.path.realpath(os.path.split(sys.argv[0])[0])
@@ -31,10 +31,17 @@ CSourceDir = os.path.join(BaseToolsDir, 'Source', 'C')
PythonSourceDir = os.path.join(BaseToolsDir, 'Source', 'Python')
TestTempDir = os.path.join(TestsDir, 'TestTempDir')
+if PythonSourceDir not in sys.path:
+ #
+ # Allow unit tests to import BaseTools python modules. This is very useful
+ # for writing unit tests.
+ #
+ sys.path.append(PythonSourceDir)
+
def MakeTheTestSuite(localItems):
tests = []
for name, item in localItems.iteritems():
- if isinstance(item, types.TypeType):
+ if isinstance(item, type):
if issubclass(item, unittest.TestCase):
tests.append(unittest.TestLoader().loadTestsFromTestCase(item))
elif issubclass(item, unittest.TestSuite):
@@ -84,9 +91,9 @@ class BaseToolsTest(unittest.TestCase):
os.remove(path)
def DisplayBinaryData(self, description, data):
- print description, '(base64 encoded):'
+ print(description, '(base64 encoded):')
b64data = base64.b64encode(data)
- print b64data
+ print(b64data)
def DisplayFile(self, fileName):
sys.stdout.write(self.ReadTmpFile(fileName))