summaryrefslogtreecommitdiff
path: root/src/engine/SCons/SConfTests.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/SConfTests.py')
-rw-r--r--src/engine/SCons/SConfTests.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py
index 69bd0a6..a05eec4 100644
--- a/src/engine/SCons/SConfTests.py
+++ b/src/engine/SCons/SConfTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/SConfTests.py 72ae09dc35ac2626f8ff711d8c4b30b6138e08e3 2019-08-08 14:50:06 bdeegan"
+__revision__ = "src/engine/SCons/SConfTests.py bee7caf9defd6e108fc2998a2520ddb36a967691 2019-12-17 02:07:09 bdeegan"
import SCons.compat
@@ -56,6 +56,18 @@ class SConfTestCase(unittest.TestCase):
os.chdir(self.save_cwd)
def _resetSConfState(self):
+ if sys.platform in ['cygwin', 'win32'] and sys.version_info.major == 2:
+ # On Windows with Python2, SCons.Platform.win32 redefines the
+ # built-in file() and open() functions to disable handle
+ # inheritance. Because we are unloading all SCons modules other
+ # than SCons.Compat, SCons.Platform.win32 will lose the variables
+ # it needs. As a result, we should reset the file() and open()
+ # functions to their original built-in versions.
+ import __builtin__
+ import SCons.Platform.win32
+ __builtin__.file = SCons.Platform.win32._builtin_file
+ __builtin__.open = SCons.Platform.win32._builtin_open
+
# Ok, this is tricky, and i do not know, if everything is sane.
# We try to reset scons' state (including all global variables)
import SCons.SConsign
@@ -90,22 +102,6 @@ class SConfTestCase(unittest.TestCase):
global existing_lib
existing_lib = 'm'
- if sys.platform in ['cygwin', 'win32']:
- # On Windows, SCons.Platform.win32 redefines the builtin
- # file() and open() functions to close the file handles.
- # This interferes with the unittest.py infrastructure in
- # some way. Just sidestep the issue by restoring the
- # original builtin functions whenever we have to reset
- # all of our global state.
-
- import SCons.Platform.win32
-
- try:
- file = SCons.Platform.win32._builtin_file
- open = SCons.Platform.win32._builtin_open
- except AttributeError:
- pass
-
def _baseTryXXX(self, TryFunc):
# TryCompile and TryLink are much the same, so we can test them
# in one method, we pass the function as a string ('TryCompile',