diff options
author | Ralf Gommers <ralf.gommers@googlemail.com> | 2013-03-06 21:41:01 +0100 |
---|---|---|
committer | Ralf Gommers <ralf.gommers@googlemail.com> | 2013-03-06 21:44:15 +0100 |
commit | ff01555976cbbac5cb1ee9ecabc170a9d6886641 (patch) | |
tree | c5a6afab2b07a8b59f8a4cfa388301b53cd80e6d /numpy/distutils/tests | |
parent | bbcfcf6ad3cbb1cbdc348161ee44f729d41c09d1 (diff) | |
download | numpy-ff01555976cbbac5cb1ee9ecabc170a9d6886641.tar.gz |
BUG: fix issue with distutils.exec_command introduced in 1.7.0.
Closes gh-2999 and gh-2915.
There are several packages (nose, scipy.weave.inline, Sage inline Fortran) that
replace stdout, in which case it doesn't have a fileno method. This method was
attempted to be used (change in gh-2766 to fix a py3k issue).
Diffstat (limited to 'numpy/distutils/tests')
-rw-r--r-- | numpy/distutils/tests/test_exec_command.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/numpy/distutils/tests/test_exec_command.py b/numpy/distutils/tests/test_exec_command.py new file mode 100644 index 000000000..f2c4fbd13 --- /dev/null +++ b/numpy/distutils/tests/test_exec_command.py @@ -0,0 +1,29 @@ +import sys +import StringIO + +from numpy.distutils import exec_command + + +class redirect_stdout(object): + """Context manager to redirect stdout for exec_command test.""" + def __init__(self, stdout=None): + self._stdout = stdout or sys.stdout + + def __enter__(self): + self.old_stdout = sys.stdout + sys.stdout = self._stdout + + def __exit__(self, exc_type, exc_value, traceback): + self._stdout.flush() + sys.stdout = self.old_stdout + + +def test_exec_command(): + # Regression test for gh-2999 and gh-2915. + # There are several packages (nose, scipy.weave.inline, Sage inline + # Fortran) that replace stdout, in which case it doesn't have a fileno + # method. This is tested here, with a do-nothing command that fails if the + # presence of fileno() is assumed in exec_command. + with redirect_stdout(StringIO.StringIO()): + exec_command.exec_command("cd '.'") + |