Show More
@@ -32,7 +32,7 b' def test_tee_simple():' | |||||
32 |
|
32 | |||
33 | class TeeTestCase(unittest.TestCase): |
|
33 | class TeeTestCase(unittest.TestCase): | |
34 |
|
34 | |||
35 |
def tchan(self, channel |
|
35 | def tchan(self, channel): | |
36 | trap = StringIO() |
|
36 | trap = StringIO() | |
37 | chan = StringIO() |
|
37 | chan = StringIO() | |
38 | text = 'Hello' |
|
38 | text = 'Hello' | |
@@ -41,28 +41,27 b' class TeeTestCase(unittest.TestCase):' | |||||
41 | setattr(sys, channel, trap) |
|
41 | setattr(sys, channel, trap) | |
42 |
|
42 | |||
43 | tee = Tee(chan, channel=channel) |
|
43 | tee = Tee(chan, channel=channel) | |
|
44 | ||||
44 | print(text, end='', file=chan) |
|
45 | print(text, end='', file=chan) | |
45 | setattr(sys, channel, std_ori) |
|
|||
46 | trap_val = trap.getvalue() |
|
46 | trap_val = trap.getvalue() | |
47 | nt.assert_equal(chan.getvalue(), text) |
|
47 | nt.assert_equal(chan.getvalue(), text) | |
48 | if check=='close': |
|
48 | ||
49 |
|
|
49 | tee.close() | |
50 | else: |
|
50 | ||
51 | del tee |
|
51 | setattr(sys, channel, std_ori) | |
|
52 | assert getattr(sys, channel) == std_ori | |||
52 |
|
53 | |||
53 | def test(self): |
|
54 | def test(self): | |
54 | for chan in ['stdout', 'stderr']: |
|
55 | for chan in ['stdout', 'stderr']: | |
55 | for check in ['close', 'del']: |
|
56 | self.tchan(chan) | |
56 | self.tchan(chan, check) |
|
|||
57 |
|
57 | |||
58 | def test_io_init(): |
|
58 | def test_io_init(): | |
59 | """Test that io.stdin/out/err exist at startup""" |
|
59 | """Test that io.stdin/out/err exist at startup""" | |
60 | for name in ('stdin', 'stdout', 'stderr'): |
|
60 | for name in ('stdin', 'stdout', 'stderr'): | |
61 | cmd = "from IPython.utils import io;print(io.%s.__class__)"%name |
|
61 | cmd = "from IPython.utils import io;print(io.%s.__class__)"%name | |
62 |
|
|
62 | with Popen([sys.executable, '-c', cmd], stdout=PIPE) as p: | |
63 | stdout=PIPE) |
|
63 | p.wait() | |
64 | p.wait() |
|
64 | classname = p.stdout.read().strip().decode('ascii') | |
65 | classname = p.stdout.read().strip().decode('ascii') |
|
|||
66 | # __class__ is a reference to the class object in Python 3, so we can't |
|
65 | # __class__ is a reference to the class object in Python 3, so we can't | |
67 | # just test for string equality. |
|
66 | # just test for string equality. | |
68 | assert 'IPython.utils.io.IOStream' in classname, classname |
|
67 | assert 'IPython.utils.io.IOStream' in classname, classname | |
@@ -79,6 +78,7 b' def test_IOStream_init():' | |||||
79 | iostream = IOStream(BadStringIO()) |
|
78 | iostream = IOStream(BadStringIO()) | |
80 | iostream.write('hi, bad iostream\n') |
|
79 | iostream.write('hi, bad iostream\n') | |
81 | assert not hasattr(iostream, 'name') |
|
80 | assert not hasattr(iostream, 'name') | |
|
81 | iostream.close() | |||
82 |
|
82 | |||
83 | def test_capture_output(): |
|
83 | def test_capture_output(): | |
84 | """capture_output() context works""" |
|
84 | """capture_output() context works""" |
General Comments 0
You need to be logged in to leave comments.
Login now