##// END OF EJS Templates
Option to spew subprocess streams during tests...
Option to spew subprocess streams during tests This supersedes PR #4268. Run the tests with '--subproc-streams show' to show output from subprocesses (kernels, IPython.parallel components) in the terminal, or with '--subproc-streams discard' to send it to /dev/null. By default (or with '--subproc-streams capture') the output is piped, captured and displayed only when tests fail. But in some situations, a test fails because of an error which actually occurred earlier, so you have to see all the output.

File last commit:

r13691:d18be243
r13824:d77e2f51
Show More
test_stdout.py
53 lines | 1.5 KiB | text/x-python | PythonLexer
Thomas Kluyver
Use unicode_std_stream in nbconvert stdout writer...
r13691 # coding: utf-8
Jonathan Frederic
Added stdout writer tests
r12043 """
Module with tests for stdout
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2013, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import sys
from ...tests.base import TestsBase
from ..stdout import StdoutWriter
Thomas Kluyver
Use StringIO.StringIO on Python 2....
r13366 from IPython.utils.py3compat import PY3
if PY3:
from io import StringIO
else:
from StringIO import StringIO
Jonathan Frederic
Added stdout writer tests
r12043
#-----------------------------------------------------------------------------
# Class
#-----------------------------------------------------------------------------
class TestStdout(TestsBase):
"""Contains test functions for stdout.py"""
def test_output(self):
"""Test stdout writer output."""
# Capture the stdout. Remember original.
stdout = sys.stdout
stream = StringIO()
sys.stdout = stream
# Create stdout writer, test output
writer = StdoutWriter()
Thomas Kluyver
Use unicode_std_stream in nbconvert stdout writer...
r13691 writer.write(u'a×', {'b': 'c'})
Jonathan Frederic
Added stdout writer tests
r12043 output = stream.getvalue()
Thomas Kluyver
Use unicode_std_stream in nbconvert stdout writer...
r13691 if not PY3:
output = output.decode('utf-8')
self.fuzzy_compare(output, u'a×')
Jonathan Frederic
Added stdout writer tests
r12043
# Revert stdout
sys.stdout = stdout