1# coding: utf-8
2"""
3Module with tests for stdout
4"""
5
6#-----------------------------------------------------------------------------
7# Copyright (c) 2013, the IPython Development Team.
8#
9# Distributed under the terms of the Modified BSD License.
10#
11# The full license is in the file COPYING.txt, distributed with this software.
12#-----------------------------------------------------------------------------
13
14#-----------------------------------------------------------------------------
15# Imports
16#-----------------------------------------------------------------------------
17
18import sys
19
20from ...tests.base import TestsBase
21from ..stdout import StdoutWriter
22
23from io import StringIO
24
25
26#-----------------------------------------------------------------------------
27# Class
28#-----------------------------------------------------------------------------
29
30class TestStdout(TestsBase):
31    """Contains test functions for stdout.py"""
32
33    def test_output(self):
34        """Test stdout writer output."""
35
36        # Capture the stdout.  Remember original.
37        stdout = sys.stdout
38        stream = StringIO()
39        sys.stdout = stream
40
41        # Create stdout writer, test output
42        writer = StdoutWriter()
43        writer.write(u'a×', {'b': 'c'})
44        output = stream.getvalue()
45        self.fuzzy_compare(output, u'a×')
46
47        # Revert stdout
48        sys.stdout = stdout