diff --git a/tests/pycharting/api/test_interface.py b/tests/pycharting/api/test_interface.py index 25445ce..6923231 100644 --- a/tests/pycharting/api/test_interface.py +++ b/tests/pycharting/api/test_interface.py @@ -161,14 +161,18 @@ def test_plot_block_returns_when_shutdown_event_set(): """ class _Event: + """Fake shutdown event that reports "not set" once, then "set".""" + def __init__(self): self._checks = 0 def is_set(self): + """Return False on the first call, then True, yielding one loop iteration.""" self._checks += 1 return self._checks > 1 # False first, then True -> exactly one iteration def wait(self, timeout=None): + """Return immediately — the wait duration is irrelevant to this test.""" return None n = 10 @@ -189,10 +193,14 @@ def test_plot_block_handles_keyboard_interrupt(): """A Ctrl+C during the blocking wait stops the server and still returns success.""" class _InterruptingEvent: + """Fake shutdown event whose wait raises ``KeyboardInterrupt``.""" + def is_set(self): + """Report the event as never set, so ``plot()`` enters the blocking wait.""" return False def wait(self, timeout=None): + """Simulate a Ctrl+C arriving while the caller is blocked.""" raise KeyboardInterrupt n = 10 diff --git a/tests/pycharting/core/test_lifecycle.py b/tests/pycharting/core/test_lifecycle.py index ec72317..a73c8ab 100644 --- a/tests/pycharting/core/test_lifecycle.py +++ b/tests/pycharting/core/test_lifecycle.py @@ -282,6 +282,7 @@ def test_server_responds_after_start(wait_until): server = ChartServer() def _healthy(): + """Return the health response once it comes back 200, else None to retry.""" try: response = httpx.get(f"http://{server.host}:{server.port}/health", timeout=1) except httpx.HTTPError: @@ -303,6 +304,7 @@ def test_server_accessible_in_background(wait_until): server = ChartServer() def _healthy(): + """Return the health response once it comes back 200, else None to retry.""" try: response = httpx.get(f"http://{server.host}:{server.port}/health", timeout=1) except httpx.HTTPError: