Skip to content

Commit 990bc16

Browse files
committed
fix-code-and-test
1 parent ac1025f commit 990bc16

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

ipykernel/zmqshell.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ def publish( # type:ignore[override]
131131
exec_count -= 1
132132
outputs = getattr(self.shell.history_manager, "outputs", None)
133133
if outputs is not None:
134-
outputs.append(HistoryOutput(output_type="display_data", bundle=data))
134+
outputs.setdefault(exec_count, []).append(
135+
HistoryOutput(output_type="display_data", bundle=data)
136+
)
135137
self._flush_streams()
136138
if metadata is None:
137139
metadata = {}

tests/test_zmq_shell.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ def test_display_stored_in_history(self):
217217
# Mock shell with history manager
218218
mock_shell = MagicMock()
219219
mock_shell.execution_count = 1
220-
mock_shell.history_manager.outputs = {1: []}
220+
mock_shell.history_manager.outputs = dict()
221+
mock_shell.display_pub._in_post_execute = False
221222

222223
self.disp_pub.shell = mock_shell
223224

0 commit comments

Comments
 (0)