Skip to content

Commit

Permalink
Add a test for version_request in test_message_spec.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Dec 4, 2012
1 parent 7c4fc04 commit 8d48684
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions IPython/zmq/kernelmanager.py
Expand Up @@ -363,6 +363,12 @@ def history(self, raw=True, output=False, hist_access_type='range', **kwargs):
self._queue_send(msg)
return msg['header']['msg_id']

def version(self):
"""Request kernel version info."""
msg = self.session.msg('version_request')
self._queue_send(msg)
return msg['header']['msg_id']

def shutdown(self, restart=False):
"""Request an immediate kernel shutdown.
Expand Down
20 changes: 20 additions & 0 deletions IPython/zmq/tests/test_message_spec.py
Expand Up @@ -16,6 +16,7 @@
import nose.tools as nt

from ..blockingkernelmanager import BlockingKernelManager
from .. import ipkernel


from IPython.testing import decorators as dec
Expand Down Expand Up @@ -195,6 +196,12 @@ class CompleteReply(Reference):
matches = List(Unicode)


class VersionReply(Reference):
version = Enum((ipkernel.version))
version_major = Enum((ipkernel.version_major,))
version_minor = Enum((ipkernel.version_minor,))


# IOPub messages

class PyIn(Reference):
Expand Down Expand Up @@ -236,6 +243,7 @@ def _data_changed(self, name, old, new):
'object_info_reply' : OInfoReply(),
'status' : Status(),
'complete_reply' : CompleteReply(),
'version_reply': VersionReply(),
'pyin' : PyIn(),
'pyout' : PyOut(),
'pyerr' : PyErr(),
Expand Down Expand Up @@ -434,6 +442,18 @@ def test_complete():
yield nt.assert_true(name in matches, "Missing match: %r" % name)


@dec.parametric
def test_version_request():
flush_channels()

shell = KM.shell_channel

msg_id = shell.version()
reply = shell.get_msg(timeout=2)
for tst in validate_message(reply, 'version_reply', msg_id):
yield tst


# IOPub channel


Expand Down

0 comments on commit 8d48684

Please sign in to comment.