Skip to content

[FIX] odoo_test_xmlrunner: attribute class-level errors to the right file - #3689

Closed
yajo wants to merge 15 commits into
OCA:19.0from
moduon:19.0-odoo_test_xmlrunner-fix-junit-wrong-file
Closed

[FIX] odoo_test_xmlrunner: attribute class-level errors to the right file#3689
yajo wants to merge 15 commits into
OCA:19.0from
moduon:19.0-odoo_test_xmlrunner-fix-junit-wrong-file

Conversation

@yajo

@yajo yajo commented Jul 30, 2026

Copy link
Copy Markdown
Member

Bug

Forward-port of the 18.0 fix for _ErrorHolder instances generated by failing setUpClass/tearDownClass. Because xmlrunner.result._XMLTestResult.startTest is never called for these holders, self.filename keeps the value from the previous test, so the JUnit report attributes the failure to the wrong source file and leaves classname empty.

Fix

Parse the _ErrorHolder description (setUpClass/tearDownClass (module.ClassName)), use inspect to locate the real test class, and patch the stored _TestInfo in addError/addFailure so the generated XML points to the correct file and line.

A regression test is included.

Related: #3688

Assisted-by: OpenCode + kimi-k2.7-code

madecsmile and others added 15 commits July 29, 2026 10:45
Also implement a better patch and merge test results.
…ke sense to make this module auto installable. - As the module depends only on 'base' AND introduces a new external dependency to an extra library (unittest-xml-reporting) all the instances that are cloning server-tools repo will have trouble, because it will not be possible to install this module, due to missing dependency
…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

yajo commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

Sorry I thought the module was already in OCA. I'll add the commit to #3598 instead.

@yajo yajo closed this Jul 30, 2026
@yajo
yajo deleted the 19.0-odoo_test_xmlrunner-fix-junit-wrong-file branch July 30, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants