Skip to content
Open
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
8 changes: 8 additions & 0 deletions tests/pycharting/api/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/pycharting/core/test_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down