[FIX] odoo_test_xmlrunner: attribute class-level errors to the right file - #3688
Open
yajo wants to merge 1 commit into
Open
[FIX] odoo_test_xmlrunner: attribute class-level errors to the right file#3688yajo wants to merge 1 commit into
yajo wants to merge 1 commit into
Conversation
yajo
force-pushed
the
18.0-odoo_test_xmlrunner-fix-junit-wrong-file
branch
from
July 30, 2026 07:51
36228c4 to
a4c2b0b
Compare
Member
Author
yajo
force-pushed
the
18.0-odoo_test_xmlrunner-fix-junit-wrong-file
branch
2 times, most recently
from
July 30, 2026 08:16
be624f1 to
3e279ce
Compare
…file When setUpClass or tearDownClass fails, unittest creates an _ErrorHolder without running _XMLTestResult.startTest, so xmlrunner kept the source file of the previous test in self.filename. This made the JUnit report assign the failure to an unrelated module and left classname empty. Resolve the real test class from the _ErrorHolder description (setUpClass/tearDownClass (module.ClassName)), look up its source file and line with inspect, and patch the stored test info in addError/addFailure before the report is generated. Include a regression test that reproduces the wrong-file issue and verifies the fix. Assisted-by: OpenCode + kimi-k2.7-code
yajo
force-pushed
the
18.0-odoo_test_xmlrunner-fix-junit-wrong-file
branch
from
July 30, 2026 08:16
3e279ce to
be2bb9b
Compare
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.

Bug
When a
setUpClassortearDownClassfails, unittest creates an_ErrorHolder. Becausexmlrunner.result._XMLTestResult.startTestis never called for these holders,self.filenamekeeps the value from the previous test. The JUnit report then attributes the failure to the wrong source file and leavesclassnameempty.This was visible in the failing pipeline: https://gitlab.com/moduon/ataraxia/buffet-odoo/-/pipelines/2714813530/test_report?job_name=unittest%3A%20%5B19%5D
Fix
Parse the
_ErrorHolderdescription (setUpClass/tearDownClass (module.ClassName)), useinspectto locate the real test class, and patch the stored_TestInfoinaddError/addFailureso the generated XML points to the correct file and line.A regression test is included.
Forward-port: #3689
Assisted-by: OpenCode + kimi-k2.7-code