##// END OF EJS Templates
Merging Fernando's trunk (fp-trunk-dev) and Brian's edits (fp-review)....
Merging Fernando's trunk (fp-trunk-dev) and Brian's edits (fp-review). This is a huge merge of months worth of work by Fernando and Brian. Some highlights: * The test suite has been ported to use the new APIs. * The test suite runs and passes on all platforms!!! * The IPython Sphinx directive has been updated to use the new APIs. * %history works again. * New %tb magic for showing last traceback. * Significant design improvements in the config loaders and applications. * Zillions of bugs fixed. * Completely new %pylab implementation that uses the new GUI support. This allows pylab to be enabled *at runtime*. * Many other things.

File last commit:

r2510:fe93ed21
r2515:08ca9176 merge
Show More
test_redirectors.py
79 lines | 2.5 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.
"""
Brian Granger
Commiting fixes for running our test suite using trial and nose....
r1963 #-----------------------------------------------------------------------------
# Copyright (C) 2008-2009 The IPython Development Team
Gael Varoquaux
More tests for frontends.
r1457 #
# Distributed under the terms of the BSD License. The full license is
# in the file COPYING, distributed as part of this software.
Brian Granger
Commiting fixes for running our test suite using trial and nose....
r1963 #-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Gael Varoquaux
More tests for frontends.
r1457
Brian Granger
Fixing misc testing related things.
r1960 # Tell nose to skip this module
__test__ = {}
gvaroquaux
BUG: redirector_output_trap was not closing properly the stdout.
r1456
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422 from cStringIO import StringIO
Brian Granger
Commiting fixes for running our test suite using trial and nose....
r1963 import os
Fernando Perez
Fix the two Twisted trial errors under win32....
r2462 import sys
Brian Granger
Commiting fixes for running our test suite using trial and nose....
r1963
from twisted.trial import unittest
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422
Brian Granger
Reverted decorators_trial.py and added command line docs....
r2510 from IPython.testing import decorators_trial as dec
Fernando Perez
Add new decorators to skip os-specific tests....
r1721 #-----------------------------------------------------------------------------
Brian Granger
Commiting fixes for running our test suite using trial and nose....
r1963 # Tests
#-----------------------------------------------------------------------------
Fernando Perez
Add new decorators to skip os-specific tests....
r1721
Brian Granger
Commiting fixes for running our test suite using trial and nose....
r1963 class TestRedirector(unittest.TestCase):
Fernando Perez
Add new decorators to skip os-specific tests....
r1721
Brian Granger
Reverted decorators_trial.py and added command line docs....
r2510 @dec.skip_win32
Brian Granger
Commiting fixes for running our test suite using trial and nose....
r1963 def test_redirector(self):
"""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()
result1 = out.getvalue()
result2 = "".join("%ic\n%i\n" %(i, i) for i in range(10))
self.assertEquals(result1, result2)
Brian Granger
Reverted decorators_trial.py and added command line docs....
r2510 @dec.skip_win32
Brian Granger
Commiting fixes for running our test suite using trial and nose....
r1963 def test_redirector_output_trap(self):
"""Check the greedy trapping behavior of the traps.
This test check not only that the redirector_output_trap does
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422 trap the output, but also that it does it in a gready way, that
gvaroquaux
More tests....
r1460 is by calling the callback ASAP.
Brian Granger
Commiting fixes for running our test suite using trial and nose....
r1963 """
Fernando Perez
Fix the two Twisted trial errors under win32....
r2462 from IPython.kernel.core.redirector_output_trap import \
RedirectorOutputTrap
Brian Granger
Commiting fixes for running our test suite using trial and nose....
r1963 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
Gael Varoquaux
Add OS-level output capture, using file-descriptor redirection.
r1422 trap.unset()
Brian Granger
Commiting fixes for running our test suite using trial and nose....
r1963 result1 = out.getvalue()
result2 = "".join("%ic\n%ip\n%i\n" %(i, i, i) for i in range(10))
self.assertEquals(result1, result2)