Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions testing/src/scenario/_ops_main_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ def _emit(self, event: ops.EventBase):
):
# Dump/undump the event to ensure any custom attributes are (re)set by restore().
event.restore(event.snapshot())
self._context.emitted_events.append(event)
# In the future, we will only store this on the manager.
self._context._emitted_events.append(event)
if self._context._manager is not None:
self._context._manager.emitted_events.append(event)

return super()._emit(event)

Expand All @@ -320,6 +323,9 @@ def _reemit(self, single_event_path: str | None = None):

# Dump/undump the event to ensure any custom attributes are (re)set by restore().
event.restore(event.snapshot())
self._context.emitted_events.append(event)
# In the future, we will only store this on the manager.
self._context._emitted_events.append(event)
if self._context._manager is not None:
self._context._manager.emitted_events.append(event)

return super()._reemit(single_event_path)
7 changes: 5 additions & 2 deletions testing/src/scenario/_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def exec(
self,
state: State,
event: _Event,
context: Context,
context: Context[CharmType],
):
"""Runs an event with this state as initial state on a charm.

Expand Down Expand Up @@ -341,7 +341,10 @@ def exec(
finally:
if ops:
ops.destroy()
context.trace_data.extend(ops.trace_data)
# In the future, we will only store this on the manager.
context._trace_data.extend(ops.trace_data)
if context._manager is not None:
context._manager.trace_data.extend(ops.trace_data)
for key in tuple(os.environ):
if key not in previous_env:
del os.environ[key]
Expand Down
Loading
Loading