Skip to content

Commit db70566

Browse files
Fix stream output (#294)
* Fix stream output * Fix tests
1 parent 5de54c8 commit db70566

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

jupyter_ydoc/ynotebook.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@ def create_ycell(self, value: Dict[str, Any]) -> Map:
166166
outputs = cell.get("outputs", [])
167167
for idx, output in enumerate(outputs):
168168
if output.get("output_type") == "stream":
169-
output["text"] = Array(output.get("text", []))
169+
text = output.get("text", "")
170+
if isinstance(text, str):
171+
ytext = Text(text)
172+
else:
173+
ytext = Text("".join(text))
174+
output["text"] = ytext
170175
outputs[idx] = Map(output)
171176
cell["outputs"] = Array(outputs)
172177
cell["execution_state"] = "idle"

tests/test_pycrdt_yjs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async def test_ypy_yjs_1(yws_server, yjs_client):
9090
ydoc, Websocket(websocket, room_name)
9191
):
9292
output_text = ynotebook.ycells[0]["outputs"][0]["text"]
93-
assert output_text.to_py() == ["Hello,"]
93+
assert output_text.to_py() == "Hello,"
9494
event = Event()
9595

9696
def callback(_event):
@@ -101,7 +101,7 @@ def callback(_event):
101101
with move_on_after(10):
102102
await event.wait()
103103

104-
assert output_text.to_py() == ["Hello,", " World!"]
104+
assert output_text.to_py() == "Hello,", " World!"
105105

106106

107107
def test_plotly_renderer():

0 commit comments

Comments
 (0)