Show More
@@ -11,8 +11,6 b' from io import StringIO' | |||||
11 | from subprocess import Popen, PIPE |
|
11 | from subprocess import Popen, PIPE | |
12 | import unittest |
|
12 | import unittest | |
13 |
|
13 | |||
14 | import nose.tools as nt |
|
|||
15 |
|
||||
16 | from IPython.utils.io import IOStream, Tee, capture_output |
|
14 | from IPython.utils.io import IOStream, Tee, capture_output | |
17 |
|
15 | |||
18 |
|
16 | |||
@@ -22,7 +20,7 b' def test_tee_simple():' | |||||
22 | text = 'Hello' |
|
20 | text = 'Hello' | |
23 | tee = Tee(chan, channel='stdout') |
|
21 | tee = Tee(chan, channel='stdout') | |
24 | print(text, file=chan) |
|
22 | print(text, file=chan) | |
25 |
|
|
23 | assert chan.getvalue() == text + "\n" | |
26 |
|
24 | |||
27 |
|
25 | |||
28 | class TeeTestCase(unittest.TestCase): |
|
26 | class TeeTestCase(unittest.TestCase): | |
@@ -39,7 +37,7 b' class TeeTestCase(unittest.TestCase):' | |||||
39 |
|
37 | |||
40 | print(text, end='', file=chan) |
|
38 | print(text, end='', file=chan) | |
41 | trap_val = trap.getvalue() |
|
39 | trap_val = trap.getvalue() | |
42 |
|
|
40 | self.assertEqual(chan.getvalue(), text) | |
43 |
|
41 | |||
44 | tee.close() |
|
42 | tee.close() | |
45 |
|
43 | |||
@@ -82,8 +80,8 b' class TestIOStream(unittest.TestCase):' | |||||
82 | """capture_output() context works""" |
|
80 | """capture_output() context works""" | |
83 |
|
81 | |||
84 | with capture_output() as io: |
|
82 | with capture_output() as io: | |
85 |
print( |
|
83 | print("hi, stdout") | |
86 |
print( |
|
84 | print("hi, stderr", file=sys.stderr) | |
87 |
|
85 | |||
88 |
|
|
86 | self.assertEqual(io.stdout, "hi, stdout\n") | |
89 |
|
|
87 | self.assertEqual(io.stderr, "hi, stderr\n") |
General Comments 0
You need to be logged in to leave comments.
Login now