forked from ipython/ipykernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensures all expected APIs are present and raise appropriate errors for undefined methods, rather than AttributeError.
- Loading branch information
Showing
2 changed files
with
46 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Test IO capturing functionality""" | ||
|
||
import io | ||
|
||
import zmq | ||
|
||
from jupyter_client.session import Session | ||
from ipykernel.iostream import IOPubThread, OutStream | ||
|
||
import nose.tools as nt | ||
|
||
def test_io_api(): | ||
"""Test that wrapped stdout has the same API as a normal TextIO object""" | ||
session = Session() | ||
ctx = zmq.Context() | ||
pub = ctx.socket(zmq.PUB) | ||
thread = IOPubThread(pub) | ||
thread.start() | ||
|
||
stream = OutStream(session, thread, 'stdout') | ||
|
||
# cleanup unused zmq objects before we start testing | ||
thread.stop() | ||
thread.close() | ||
ctx.term() | ||
|
||
assert stream.errors is None | ||
assert not stream.isatty() | ||
with nt.assert_raises(io.UnsupportedOperation): | ||
stream.detach() | ||
with nt.assert_raises(io.UnsupportedOperation): | ||
next(stream) | ||
with nt.assert_raises(io.UnsupportedOperation): | ||
stream.read() | ||
with nt.assert_raises(io.UnsupportedOperation): | ||
stream.readline() | ||
with nt.assert_raises(io.UnsupportedOperation): | ||
stream.seek() | ||
with nt.assert_raises(io.UnsupportedOperation): | ||
stream.tell() | ||
|
||
|