Show More
@@ -0,0 +1,51 b'' | |||||
|
1 | """ | |||
|
2 | Module with tests for debug | |||
|
3 | """ | |||
|
4 | ||||
|
5 | #----------------------------------------------------------------------------- | |||
|
6 | # Copyright (c) 2013, the IPython Development Team. | |||
|
7 | # | |||
|
8 | # Distributed under the terms of the Modified BSD License. | |||
|
9 | # | |||
|
10 | # The full license is in the file COPYING.txt, distributed with this software. | |||
|
11 | #----------------------------------------------------------------------------- | |||
|
12 | ||||
|
13 | #----------------------------------------------------------------------------- | |||
|
14 | # Imports | |||
|
15 | #----------------------------------------------------------------------------- | |||
|
16 | ||||
|
17 | import sys | |||
|
18 | from StringIO import StringIO | |||
|
19 | ||||
|
20 | from ...tests.base import TestsBase | |||
|
21 | from ..debug import DebugWriter | |||
|
22 | ||||
|
23 | ||||
|
24 | #----------------------------------------------------------------------------- | |||
|
25 | # Class | |||
|
26 | #----------------------------------------------------------------------------- | |||
|
27 | ||||
|
28 | class TestDebug(TestsBase): | |||
|
29 | """Contains test functions for debug.py""" | |||
|
30 | ||||
|
31 | def test_output(self): | |||
|
32 | """Test debug writer output.""" | |||
|
33 | ||||
|
34 | # Capture the stdout. Remember original. | |||
|
35 | stdout = sys.stdout | |||
|
36 | stream = StringIO() | |||
|
37 | sys.stdout = stream | |||
|
38 | ||||
|
39 | # Create stdout writer, get output | |||
|
40 | writer = DebugWriter() | |||
|
41 | writer.write('aaa', {'outputs': {'bbb': 'ccc'}}) | |||
|
42 | output = stream.getvalue() | |||
|
43 | ||||
|
44 | # Check output. Make sure resources dictionary is dumped, but nothing | |||
|
45 | # else. | |||
|
46 | assert 'aaa' not in output | |||
|
47 | assert 'bbb' in output | |||
|
48 | assert 'ccc' in output | |||
|
49 | ||||
|
50 | # Revert stdout | |||
|
51 | sys.stdout = stdout No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now