Show More
@@ -28,12 +28,33 b' from types import MethodType' | |||||
28 | # our own |
|
28 | # our own | |
29 | from . import tools |
|
29 | from . import tools | |
30 |
|
30 | |||
|
31 | from IPython.utils import io | |||
31 | from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell |
|
32 | from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell | |
32 |
|
33 | |||
33 | #----------------------------------------------------------------------------- |
|
34 | #----------------------------------------------------------------------------- | |
34 | # Functions |
|
35 | # Functions | |
35 | #----------------------------------------------------------------------------- |
|
36 | #----------------------------------------------------------------------------- | |
36 |
|
37 | |||
|
38 | class StreamProxy(io.IOStream): | |||
|
39 | """Proxy for sys.stdout/err. This will request the stream *at call time* | |||
|
40 | allowing for nose's Capture plugin's redirection of sys.stdout/err. | |||
|
41 | ||||
|
42 | Parameters | |||
|
43 | ---------- | |||
|
44 | name : str | |||
|
45 | The name of the stream. This will be requested anew at every call | |||
|
46 | """ | |||
|
47 | ||||
|
48 | def __init__(self, name): | |||
|
49 | self.name=name | |||
|
50 | ||||
|
51 | @property | |||
|
52 | def stream(self): | |||
|
53 | return getattr(sys, self.name) | |||
|
54 | ||||
|
55 | def flush(self): | |||
|
56 | self.stream.flush() | |||
|
57 | ||||
37 | # Hack to modify the %run command so we can sync the user's namespace with the |
|
58 | # Hack to modify the %run command so we can sync the user's namespace with the | |
38 | # test globals. Once we move over to a clean magic system, this will be done |
|
59 | # test globals. Once we move over to a clean magic system, this will be done | |
39 | # with much less ugliness. |
|
60 | # with much less ugliness. | |
@@ -191,5 +212,9 b' def start_ipython():' | |||||
191 | get_ipython = _ip.get_ipython |
|
212 | get_ipython = _ip.get_ipython | |
192 | __builtin__._ip = _ip |
|
213 | __builtin__._ip = _ip | |
193 | __builtin__.get_ipython = get_ipython |
|
214 | __builtin__.get_ipython = get_ipython | |
|
215 | ||||
|
216 | # To avoid extra IPython messages during testing, suppress io.stdout/stderr | |||
|
217 | io.stdout = StreamProxy('stdout') | |||
|
218 | io.stderr = StreamProxy('stderr') | |||
194 |
|
219 | |||
195 | return _ip |
|
220 | return _ip |
General Comments 0
You need to be logged in to leave comments.
Login now