Fix test_expect_unity_test_ouput failure caused by DutGroup class attribute on Dut#1
Closed
Copilot wants to merge 4 commits intofeat/groupfrom
Closed
Fix test_expect_unity_test_ouput failure caused by DutGroup class attribute on Dut#1Copilot wants to merge 4 commits intofeat/groupfrom
Copilot wants to merge 4 commits intofeat/groupfrom
Conversation
… class body Agent-Logs-Url: https://github.com/lucasssvaz/pytest-embedded/sessions/052d2f4e-9bf1-42c3-88b6-b3bdbea2c19e Co-authored-by: lucasssvaz <32426024+lucasssvaz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix failing test_expect_unity_test_ouput due to DutGroup
Fix test_expect_unity_test_ouput failure caused by DutGroup class attribute on Dut
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_expect_unity_test_ouputwas producingerrors: 1, failed: 0instead offailed: 2in its inner sub-pytest session on Python 3.10. The root cause wasDutGroup = DutGroupdefined inside theDutclass body, which interfered with pytest's in-process fixture setup/collection when running nested sessions viatestdir.runpytest().Change
pytest_embedded/dut.pyDutGroup = DutGroupfrom inside theDutclass bodyDut.DutGroupremains accessible as before, soDut.DutGroup(dut[0], dut[1])usage intest_multi_dutis unaffected.Original prompt
Problem
The test
test_expect_unity_test_ouputinpytest-embedded/tests/test_base.pyis failing after the introduction ofDutGroupin PR espressif#415.Failing test
The test expects 2 failed outcomes and 0 errors, but instead gets 0 failures and 1 error.
Root cause
The test
test_expect_unity_test_ouput(inpytest-embedded/tests/test_base.py) spawns a sub-pytest session viatestdir.runpytest(). The sub-session creates two tests (test_expect_unity_test_output_basicandtest_expect_unity_test_output_fixture) that are expected to fail (not error). The sub-session is encountering an error during setup, likely caused by a side effect from theDutGroupintroduction — specifically the addition ofDutGroup = DutGroupas a class attribute onDutindut.py, which may be interfering with fixture setup/collection in the sub-test session.Files changed in the PR
pytest-embedded/pytest_embedded/group.py— new file implementingDutGroupandDutGroupMemberErrorpytest-embedded/pytest_embedded/dut.py— addedDutGroup = DutGroupclass attribute onDutpytest-embedded/pytest_embedded/__init__.py— exportedDutGroup,DutGroupMemberErrorpytest-embedded/tests/test_base.py— addedtest_multi_duttest and other tests referencingDutGroupWhat needs to be fixed
Investigate and fix the root cause of
test_expect_unity_test_ouputnow producingerrors: 1instead offailed: 2. The fix should be in the source code (likelygroup.py,dut.py, orplugin.py) so that the sub-pytest session correctly gets 2failedoutcomes and 0errors, without breaking the newtest_multi_duttests.The fix must not simply skip the assertion or catch the error — it must address the underlying issue causing setup to error instead of the test body running and failing.
Current test file content (for reference)
The relevant failing test is
test_expect_unity_test_ouputat line ~542 inpytest-embedded/tests/test_base.py. It spawns a sub-session with two inner tests that each write Unity-format test output and calldut.expect_unity_test_output(), which should raiseAssertionError('Unity test failed')— making them fail, not error.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Is these errors related to my PR ?
https://github.com/espressif/pytest-embedded/actions/runs/24267653171/job/70866024587?pr=415
Assistant: Now let me look at the specific failing test to understand if it's related to PR espressif#415:
Assistant: Yes, the failing test
test_expect_unity_test_ouputinpytest-embedded/tests/test_base.py:601is related to your PR.What's failing
The test at line 542–603 expects 2 failed tests and 0 errors:
But instead it got 0 failures and 1 error:
Why it's related to your PR
Your PR added a new
test_multi_duttest intest_base.py(lines 100–282) which importsDutGroupandDutGroupMemberErrorfrompytest_embedded. The inner test file created bytest_expect_unity_test_ouputalso runs inside the sametestdir, and the sub-test session is likely failing during setup/collection rather than executing the two tests — producing anerrorinstead offailed.The most probable cause is that your new
group.pymodule or the changes todut.py(addingDutGroup = DutGroupas a class attribute) introduced a side effect that causes the sub-pytestsession spawned bytestdir.runpytest()to error during setup rat...This pull request was created from Copilot chat.