From 9054331c371c00d1513e07c65f08f05008648ebb Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Fri, 28 Aug 2026 09:52:08 +0530 Subject: [PATCH 1/2] fix: let the unity_tester fixture accept emulator duts The fixture yielded twice when a dut was not an `IdfDut`, so every case using it errored under `--embedded-services idf,espemu` or `idf,qemu`. Accept any dut carrying `IdfUnityDutMixin`, which is what `CaseTester` actually needs. --- pytest-embedded/pytest_embedded/plugin.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pytest-embedded/pytest_embedded/plugin.py b/pytest-embedded/pytest_embedded/plugin.py index 70af0d45..d6c27029 100644 --- a/pytest-embedded/pytest_embedded/plugin.py +++ b/pytest-embedded/pytest_embedded/plugin.py @@ -1349,16 +1349,19 @@ def dut( @pytest.fixture def unity_tester(dut: t.Union['IdfDut', tuple['IdfDut']]) -> t.Optional['CaseTester']: try: - from pytest_embedded_idf import CaseTester, IdfDut + from pytest_embedded_idf import CaseTester + from pytest_embedded_idf.unity_tester import IdfUnityDutMixin except ImportError: yield None else: - # all dut instance must be IdfDut to use this fixture - for _dut in to_list(dut): - if not isinstance(_dut, IdfDut): - yield None - - yield CaseTester(to_list(dut)) + duts = to_list(dut) + # `CaseTester` drives the unity test menu, which every dut carrying + # `IdfUnityDutMixin` provides: `IdfDut` inherits it, and the dut factory + # mixes it into the qemu and esp-emu duts when the idf service is used. + if all(isinstance(_dut, IdfUnityDutMixin) for _dut in duts): + yield CaseTester(duts) + else: + yield None ################## From c6e39cc2b7186950c29b6a052718c3f36c54962a Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Fri, 28 Aug 2026 17:36:28 +0530 Subject: [PATCH 2/2] test: stop the writer thread with the test that starts it test_expect_from_timeout left a daemon thread writing for 7.5s while the test returned after 4s, so it wrote into a torn-down queue and raised BrokenPipeError after the session. pytest reported that against whichever test ran next. --- pytest-embedded/tests/test_base.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pytest-embedded/tests/test_base.py b/pytest-embedded/tests/test_base.py index ede8d19c..361baaec 100644 --- a/pytest-embedded/tests/test_base.py +++ b/pytest-embedded/tests/test_base.py @@ -334,20 +334,27 @@ def test_expect_exact_no_matching_word_pass_rest(dut): def test_expect_from_timeout(testdir): testdir.makepyfile(r""" import threading - import time import pexpect def test_expect_from_timeout(msg_queue, dut): + stop = threading.Event() + def write_bytes(): for _ in range(5): + if stop.is_set(): + return msg_queue.write('1') - time.sleep(1.5) + stop.wait(1.5) write_thread = threading.Thread(target=write_bytes, daemon=True) write_thread.start() - res = dut.expect(pexpect.TIMEOUT, timeout=4) - assert res == b'111' + try: + res = dut.expect(pexpect.TIMEOUT, timeout=4) + assert res == b'111' + finally: + stop.set() + write_thread.join(timeout=2) """) result = testdir.runpytest('-s')