##// END OF EJS Templates
Replace all use of the ast module with the codeop module, and all use of...
Replace all use of the ast module with the codeop module, and all use of the uuid module with the IPython.external.guid module. Add tests for the is_complete method.

File last commit:

r1561:fddc4586
r1710:a36c8d5b
Show More
test_redirectors.py
68 lines | 1.9 KiB | text/x-python | PythonLexer
/ IPython / kernel / core / tests / test_redirectors.py
gvaroquaux
BUG: redirector_output_trap was not closing properly the stdout.
r1456 # encoding: utf-8
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422 """
Test the output capture at the OS level, using file descriptors.
"""
gvaroquaux
BUG: redirector_output_trap was not closing properly the stdout.
r1456 __docformat__ = "restructuredtext en"
Gael Varoquaux
More tests for frontends.
r1457 #-------------------------------------------------------------------------------
# Copyright (C) 2008 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is
# in the file COPYING, distributed as part of this software.
#-------------------------------------------------------------------------------
gvaroquaux
BUG: redirector_output_trap was not closing properly the stdout.
r1456
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422 import os
from cStringIO import StringIO
Brian Granger
Skipping a few tests related to the wx frontend that fail on Windows.
r1561 from IPython.testing import decorators as testdec
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422
Brian Granger
Skipping a few tests related to the wx frontend that fail on Windows.
r1561 # FIXME
@testdec.skip("This doesn't work under Windows")
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422 def test_redirector():
""" Checks that the redirector can be used to do synchronous capture.
"""
from IPython.kernel.core.fd_redirector import FDRedirector
r = FDRedirector()
out = StringIO()
try:
r.start()
for i in range(10):
os.system('echo %ic' % i)
print >>out, r.getvalue(),
print >>out, i
except:
r.stop()
raise
r.stop()
Brian Granger
Skipping a few tests related to the wx frontend that fail on Windows.
r1561 result1 = out.getvalue()
result2 = "".join("%ic\n%i\n" %(i, i) for i in range(10))
assert result1 == result2
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422
Brian Granger
Skipping a few tests related to the wx frontend that fail on Windows.
r1561 # FIXME
@testdec.skip("This doesn't work under Windows")
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422 def test_redirector_output_trap():
""" This test check not only that the redirector_output_trap does
trap the output, but also that it does it in a gready way, that
gvaroquaux
More tests....
r1460 is by calling the callback ASAP.
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422 """
from IPython.kernel.core.redirector_output_trap import RedirectorOutputTrap
out = StringIO()
trap = RedirectorOutputTrap(out.write, out.write)
try:
trap.set()
for i in range(10):
os.system('echo %ic' % i)
print "%ip" % i
print >>out, i
except:
trap.unset()
raise
trap.unset()
Brian Granger
Skipping a few tests related to the wx frontend that fail on Windows.
r1561 result1 = out.getvalue()
result2 = "".join("%ic\n%ip\n%i\n" %(i, i, i) for i in range(10))
assert result1 == result2
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422
Gael Varoquaux
More tests for frontends.
r1457
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422