Solaar/tests
Ken Sanislo 25865994cb
device: Treat empty hidraw read as device removal (EOF) (#3174)
* Treat empty hidraw read as device removal (EOF)

When select() reports a hidraw fd as readable but os.read() returns
empty bytes, that's EOF per POSIX — the device has been removed.
Previously this was silently treated as no data, causing the listener
to loop indefinitely on a gone device instead of cleaning up.

* Fix test_ping_errors missing mocks for _read_input_buffer and write

The test was not mocking _read_input_buffer or write, so ping() would
call into real hidapi.read() with a fake handle (fd 1). The empty-read
EOF detection added in the previous commit made this consistently fail
by raising OSError → NoReceiver before reaching the mocked _read path.

Add the same mocks used by the adjacent test_request_errors.

---------

Co-authored-by: Peter F. Patel-Schneider <pfpschneider@gmail.com>
2026-04-14 11:56:01 -04:00
..
hid_parser Introduce hid_parser tests 2024-09-15 09:19:13 -04:00
hidapi hidapi: Explicitly load hidapi/udev implementation 2024-10-11 07:42:38 -04:00
logitech_receiver device: Treat empty hidraw read as device removal (EOF) (#3174) 2026-04-14 11:56:01 -04:00
solaar test_pair_window: Simplify tests by cleaning up receiver mock (#2899) 2025-12-10 10:50:07 -05:00
test_keysyms keysyms: Introduce tests for this package 2024-10-11 07:42:38 -04:00
__init__.py tests: Introduce tests with pytest 2024-02-10 13:58:20 -05:00