summaryrefslogtreecommitdiff
path: root/numpy/distutils/tests/test_exec_command.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-04-06 07:42:08 -0700
committerCharles Harris <charlesr.harris@gmail.com>2013-04-06 07:42:08 -0700
commit49a8902a673d6fb2ba9ca446fc652aa9d2e55e1b (patch)
treee71c0d8f6123307860a58796ed840bf32526b3fe /numpy/distutils/tests/test_exec_command.py
parent3c8fc14665548c71a9cd144b2e16d9309a92e255 (diff)
parent4394515cd5632a7f110993ff75033d407d10861d (diff)
downloadnumpy-49a8902a673d6fb2ba9ca446fc652aa9d2e55e1b.tar.gz
Merge pull request #3191 from charris/2to3-apply-imports-fixer
2to3: Apply `imports` fixer.
Diffstat (limited to 'numpy/distutils/tests/test_exec_command.py')
-rw-r--r--numpy/distutils/tests/test_exec_command.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/numpy/distutils/tests/test_exec_command.py b/numpy/distutils/tests/test_exec_command.py
index 11f262369..3e85fcd3e 100644
--- a/numpy/distutils/tests/test_exec_command.py
+++ b/numpy/distutils/tests/test_exec_command.py
@@ -2,11 +2,16 @@ from __future__ import division, absolute_import
import os
import sys
-import StringIO
from tempfile import TemporaryFile
from numpy.distutils import exec_command
+# In python 3 stdout, stderr are text (unicode compliant) devices, so to
+# emulate them import StringIO from the io module.
+if sys.version_info[0] >= 3:
+ from io import StringIO
+else:
+ from StringIO import StringIO
class redirect_stdout(object):
"""Context manager to redirect stdout for exec_command test."""
@@ -62,26 +67,26 @@ def test_exec_command_stdout():
# both that the special case works and that the generic code works.
# Test posix version:
- with redirect_stdout(StringIO.StringIO()):
+ with redirect_stdout(StringIO()):
with redirect_stderr(TemporaryFile()):
exec_command.exec_command("cd '.'")
if os.name == 'posix':
# Test general (non-posix) version:
with emulate_nonposix():
- with redirect_stdout(StringIO.StringIO()):
+ with redirect_stdout(StringIO()):
with redirect_stderr(TemporaryFile()):
exec_command.exec_command("cd '.'")
def test_exec_command_stderr():
# Test posix version:
with redirect_stdout(TemporaryFile(mode='w+')):
- with redirect_stderr(StringIO.StringIO()):
+ with redirect_stderr(StringIO()):
exec_command.exec_command("cd '.'")
if os.name == 'posix':
# Test general (non-posix) version:
with emulate_nonposix():
with redirect_stdout(TemporaryFile()):
- with redirect_stderr(StringIO.StringIO()):
+ with redirect_stderr(StringIO()):
exec_command.exec_command("cd '.'")