feat: execute cells through persistent Jupyter kernel

This commit is contained in:
lda
2026-08-30 18:37:06 +07:00 Verified
parent 27a1292108
commit 01c06218fb
2 changed files with 112 additions and 1 deletions
+20 -1
View File
@@ -1,6 +1,6 @@
import unittest
from ipython_shell.transport import KernelMessage
from ipython_shell.transport import JupyterTransport, KernelMessage
class TransportTests(unittest.TestCase):
@@ -17,5 +17,24 @@ class TransportTests(unittest.TestCase):
self.assertEqual(message.buffers, [b"binary"])
class AsyncTransportTests(unittest.IsolatedAsyncioTestCase):
async def test_transport_executes_and_returns_execute_reply(self):
transport = JupyterTransport()
await transport.start()
try:
call_id = await transport.execute("2 + 2")
messages = [
message async for message in transport.messages_for(call_id)
]
finally:
await transport.shutdown()
self.assertTrue(
any(message.msg_type == "execute_result" for message in messages)
)
self.assertEqual(messages[-1].msg_type, "execute_reply")
self.assertEqual(messages[-1].content["status"], "ok")
if __name__ == "__main__":
unittest.main()