Show More
@@ -1,68 +1,68 b'' | |||||
1 | # encoding: utf-8 |
|
1 | # encoding: utf-8 | |
2 | """ |
|
2 | """ | |
3 | Test the output capture at the OS level, using file descriptors. |
|
3 | Test the output capture at the OS level, using file descriptors. | |
4 | """ |
|
4 | """ | |
5 |
|
5 | |||
6 | __docformat__ = "restructuredtext en" |
|
6 | __docformat__ = "restructuredtext en" | |
7 |
|
7 | |||
8 | #------------------------------------------------------------------------------- |
|
8 | #------------------------------------------------------------------------------- | |
9 | # Copyright (C) 2008 The IPython Development Team |
|
9 | # Copyright (C) 2008 The IPython Development Team | |
10 | # |
|
10 | # | |
11 | # Distributed under the terms of the BSD License. The full license is |
|
11 | # Distributed under the terms of the BSD License. The full license is | |
12 | # in the file COPYING, distributed as part of this software. |
|
12 | # in the file COPYING, distributed as part of this software. | |
13 | #------------------------------------------------------------------------------- |
|
13 | #------------------------------------------------------------------------------- | |
14 |
|
14 | |||
15 |
|
15 | |||
16 | import os |
|
16 | import os | |
17 | from cStringIO import StringIO |
|
17 | from cStringIO import StringIO | |
18 |
|
18 | |||
19 | from IPython.testing import decorators as testdec |
|
19 | # FIXME: | |
|
20 | import nose | |||
|
21 | import sys | |||
|
22 | if sys.platform == 'win32': | |||
|
23 | raise nose.SkipTest("These tests are not reliable under windows") | |||
20 |
|
24 | |||
21 | # FIXME |
|
|||
22 | @testdec.skip("This doesn't work under Windows") |
|
|||
23 | def test_redirector(): |
|
25 | def test_redirector(): | |
24 | """ Checks that the redirector can be used to do synchronous capture. |
|
26 | """ Checks that the redirector can be used to do synchronous capture. | |
25 | """ |
|
27 | """ | |
26 | from IPython.kernel.core.fd_redirector import FDRedirector |
|
28 | from IPython.kernel.core.fd_redirector import FDRedirector | |
27 | r = FDRedirector() |
|
29 | r = FDRedirector() | |
28 | out = StringIO() |
|
30 | out = StringIO() | |
29 | try: |
|
31 | try: | |
30 | r.start() |
|
32 | r.start() | |
31 | for i in range(10): |
|
33 | for i in range(10): | |
32 | os.system('echo %ic' % i) |
|
34 | os.system('echo %ic' % i) | |
33 | print >>out, r.getvalue(), |
|
35 | print >>out, r.getvalue(), | |
34 | print >>out, i |
|
36 | print >>out, i | |
35 | except: |
|
37 | except: | |
36 | r.stop() |
|
38 | r.stop() | |
37 | raise |
|
39 | raise | |
38 | r.stop() |
|
40 | r.stop() | |
39 | result1 = out.getvalue() |
|
41 | result1 = out.getvalue() | |
40 | result2 = "".join("%ic\n%i\n" %(i, i) for i in range(10)) |
|
42 | result2 = "".join("%ic\n%i\n" %(i, i) for i in range(10)) | |
41 | assert result1 == result2 |
|
43 | assert result1 == result2 | |
42 |
|
44 | |||
43 | # FIXME |
|
|||
44 | @testdec.skip("This doesn't work under Windows") |
|
|||
45 | def test_redirector_output_trap(): |
|
45 | def test_redirector_output_trap(): | |
46 | """ This test check not only that the redirector_output_trap does |
|
46 | """ This test check not only that the redirector_output_trap does | |
47 | trap the output, but also that it does it in a gready way, that |
|
47 | trap the output, but also that it does it in a gready way, that | |
48 | is by calling the callback ASAP. |
|
48 | is by calling the callback ASAP. | |
49 | """ |
|
49 | """ | |
50 | from IPython.kernel.core.redirector_output_trap import RedirectorOutputTrap |
|
50 | from IPython.kernel.core.redirector_output_trap import RedirectorOutputTrap | |
51 | out = StringIO() |
|
51 | out = StringIO() | |
52 | trap = RedirectorOutputTrap(out.write, out.write) |
|
52 | trap = RedirectorOutputTrap(out.write, out.write) | |
53 | try: |
|
53 | try: | |
54 | trap.set() |
|
54 | trap.set() | |
55 | for i in range(10): |
|
55 | for i in range(10): | |
56 | os.system('echo %ic' % i) |
|
56 | os.system('echo %ic' % i) | |
57 | print "%ip" % i |
|
57 | print "%ip" % i | |
58 | print >>out, i |
|
58 | print >>out, i | |
59 | except: |
|
59 | except: | |
60 | trap.unset() |
|
60 | trap.unset() | |
61 | raise |
|
61 | raise | |
62 | trap.unset() |
|
62 | trap.unset() | |
63 | result1 = out.getvalue() |
|
63 | result1 = out.getvalue() | |
64 | result2 = "".join("%ic\n%ip\n%i\n" %(i, i, i) for i in range(10)) |
|
64 | result2 = "".join("%ic\n%ip\n%i\n" %(i, i, i) for i in range(10)) | |
65 | assert result1 == result2 |
|
65 | assert result1 == result2 | |
66 |
|
66 | |||
67 |
|
67 | |||
68 |
|
68 |
General Comments 0
You need to be logged in to leave comments.
Login now