From 15b7f9b6519d3b5c3d4ddc2a23459ca089527fc0 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Thu, 28 Mar 2013 10:48:45 -0600 Subject: MAINT: Fix python3 ResourceWarning when running test_exec_command.py The tests in test_exec_command.py used with blocks with a context manager that could redirect stderr and stdout to temporary files but those files were not closed on exit from the block. --- numpy/distutils/tests/test_exec_command.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'numpy') diff --git a/numpy/distutils/tests/test_exec_command.py b/numpy/distutils/tests/test_exec_command.py index d38c096ba..9301a2097 100644 --- a/numpy/distutils/tests/test_exec_command.py +++ b/numpy/distutils/tests/test_exec_command.py @@ -18,6 +18,8 @@ class redirect_stdout(object): def __exit__(self, exc_type, exc_value, traceback): self._stdout.flush() sys.stdout = self.old_stdout + # note: closing sys.stdout won't close it. + self._stdout.close() class redirect_stderr(object): """Context manager to redirect stderr for exec_command test.""" @@ -31,6 +33,8 @@ class redirect_stderr(object): def __exit__(self, exc_type, exc_value, traceback): self._stderr.flush() sys.stderr = self.old_stderr + # note: closing sys.stderr won't close it. + self._stderr.close() class emulate_nonposix(object): """Context manager to emulate os.name != 'posix' """ -- cgit v1.2.1