feat: expose Jupyter shell through web app

This commit is contained in:
lda
2026-08-30 19:19:49 +07:00 Verified
parent a77f146a72
commit 6315235e16
11 changed files with 220 additions and 9 deletions
+49 -3
View File
@@ -1,9 +1,9 @@
import asyncio
import unittest
from ipython_shell.jupyter_app import JupyterApp
from ipython_shell.jupyter_shell import JupyterShell
from ipython_shell.transport import InputRequest, KernelMessage
from ipython_shell.jupyter.app import JupyterApp
from ipython_shell.jupyter.shell import JupyterShell
from ipython_shell.jupyter.transport import InputRequest, KernelMessage
class JupyterShellTests(unittest.IsolatedAsyncioTestCase):
@@ -48,6 +48,52 @@ class JupyterShellTests(unittest.IsolatedAsyncioTestCase):
class JupyterAppTests(unittest.IsolatedAsyncioTestCase):
async def test_named_shells_have_isolated_namespaces(self):
app = JupyterApp()
try:
_alpha_setup = [
message
async for message in app.run_code_stream(
"alpha_only = 'alpha'",
shell_name="alpha",
)
]
beta_view = [
message
async for message in app.run_code_stream(
"'alpha_only' in globals()",
shell_name="beta",
)
]
alpha_view = [
message
async for message in app.run_code_stream(
"alpha_only",
shell_name="alpha",
)
]
finally:
await app.shutdown()
self.assertEqual(
next(
message.content["data"]["text/plain"]
for message in beta_view
if isinstance(message, KernelMessage)
and message.msg_type == "execute_result"
),
"False",
)
self.assertEqual(
next(
message.content["data"]["text/plain"]
for message in alpha_view
if isinstance(message, KernelMessage)
and message.msg_type == "execute_result"
),
"'alpha'",
)
async def test_app_routes_input_reply_to_the_call(self):
app = JupyterApp()
stream = app.run_code_stream(