From fdd8dc2587b226fc39378681c212a0ca494a7532 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Tue, 23 Jan 2024 14:54:38 +0200 Subject: [PATCH] Fix the monitor errors test on Windows and hide unhelpful warnings there --- setup.cfg | 2 ++ tests/cmd/monitor.py | 7 +++++-- yakut/__main__.py | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 97c23ab..cc101f5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -101,6 +101,8 @@ log_file_level = DEBUG # Unraisable exceptions are filtered because PyTest yields false-positives coming from PyCyphal. addopts = --doctest-modules -v -p no:unraisableexception asyncio_mode = auto +filterwarnings = + ignore:.*SDL2.*:UserWarning # ---------------------------------------- MYPY ---------------------------------------- [mypy] diff --git a/tests/cmd/monitor.py b/tests/cmd/monitor.py index 722f9dc..fa423f0 100755 --- a/tests/cmd/monitor.py +++ b/tests/cmd/monitor.py @@ -290,10 +290,13 @@ async def _run_zombie() -> None: pres = pycyphal.presentation.Presentation(tr) try: pub = pres.make_publisher(Empty_1, 99) + pub.send_timeout = 5.0 + sub = pres.make_subscriber(Empty_1, 99) # Ensure there's an RX socket on Windows. while True: - await pub.publish(Empty_1()) + assert await pub.publish(Empty_1()) await asyncio.sleep(0.5) - except (asyncio.TimeoutError, asyncio.CancelledError): # pragma: no cover + _ = await sub.receive_for(0.0) # Avoid queue overrun. + except (asyncio.TimeoutError, asyncio.CancelledError, GeneratorExit): # pragma: no cover pass finally: pres.close() diff --git a/yakut/__main__.py b/yakut/__main__.py index 8edf42f..51904a1 100644 --- a/yakut/__main__.py +++ b/yakut/__main__.py @@ -3,6 +3,10 @@ # Author: Pavel Kirienko if __name__ == "__main__": + from warnings import filterwarnings + + filterwarnings("ignore") # Warnings are meant for developers and should not be shown to users. + from yakut import main main() # pylint: disable=no-value-for-parameter