chore: apply linting fixes and expand ruff coverage to test suite

This commit is contained in:
jack
2026-07-06 15:52:53 -07:00
parent d63332d619
commit 015642eea0
24 changed files with 144 additions and 67 deletions
+6 -4
View File
@@ -1,7 +1,9 @@
import time
import time
from pygui.backend.models.frame import Frame
from pygui.serialcomm.stream_reader import StreamReader
class FakeTransport:
"""Yield canned data then blocks (returns b'')."""
def __init__(self, lines):
@@ -28,7 +30,7 @@ class FakeTransport:
self._pos = idx + 1
return res
def close(self): self.closed = True
def parse_line(raw: str, seq: int) -> Frame:
parts = [float(x) for x in raw.split(",")]
return Frame(seq = seq, time = parts[0], values = parts[1:])
@@ -38,10 +40,10 @@ def test_reads_frames_and_counts_errors():
transport = FakeTransport([b"0.0,149,148\n", b"garbage\n", b"0.5,150,149\n"])
r = StreamReader(transport, parse_line,
on_frame = got.append, on_error = lambda e: errors.append(e))
r.start()
time.sleep(0.1)
r.stop()
assert [f.values for f in got] == [[149.0, 148.0], [150.0, 149.0]]
assert r.error_count == 1
assert transport.closed
assert transport.closed