1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
"""
Module with tests for debug
"""
# -----------------------------------------------------------------------------
# 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 io import StringIO
from nbconvert.writers.debug import DebugWriter
from tests.base import TestsBase
# -----------------------------------------------------------------------------
# Class
# -----------------------------------------------------------------------------
class TestDebug(TestsBase):
"""Contains test functions for debug.py"""
def test_output(self):
"""Test debug writer output."""
# Capture the stdout. Remember original.
stdout = sys.stdout
stream = StringIO()
sys.stdout = stream
# Create stdout writer, get output
writer = DebugWriter()
writer.write("aaa", {"outputs": {"bbb": "ccc"}})
output = stream.getvalue()
# Check output. Make sure resources dictionary is dumped, but nothing
# else.
assert "aaa" not in output
assert "bbb" in output
assert "ccc" in output
# Revert stdout
sys.stdout = stdout
|