Files
DeepTutor/tests/events/test_event_bus.py
Rudy Celekli 8fa247d815 fix(events): clear the get_event_bus cache in EventBus.reset
EventBus.reset cleared the class singleton (_instance/_initialized) but not the
module-level _event_bus that get_event_bus caches. After a reset, get_event_bus
kept returning the previous, stopped bus (_running=False, processor task
cancelled), while a direct EventBus() built a fresh one — the two singleton
paths diverged. Reset the module-level reference too.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-01 09:38:01 -05:00

17 lines
503 B
Python

"""EventBus singleton reset semantics."""
from __future__ import annotations
from deeptutor.events.event_bus import EventBus, get_event_bus
def test_reset_clears_the_module_level_accessor() -> None:
# get_event_bus caches its own module-level singleton; reset() must clear it
# too, or the accessor keeps handing back a stopped bus after a reset.
first = get_event_bus()
try:
EventBus.reset()
assert get_event_bus() is not first
finally:
EventBus.reset()