Bug 13342 - Create ptest helper for python unittests
Summary: Create ptest helper for python unittests
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 2.7
Hardware: x86 Multiple
: Medium enhancement
Target Milestone: 4.3
Assignee: Ross Burton
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2019-05-09 14:05 UTC by Joshua Watt
Modified: 2023-05-04 14:49 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Watt 2019-05-09 14:05:41 UTC
It would be convenient to have a wrapper of some sort that could convert the Python unittest output to ptest compatible output. This is currently done ad-hoc with a sed line (see python3's run-ptest); creating either a wrapper for this or possibly a python test runner class that outputs the correct format directly would be useful for other ptests that are written using python unittest.
Comment 1 Ross Burton 2019-05-09 14:36:05 UTC
I did start a unittest subclass that reimplemented the output code to match what we expect, but I got stuck on making -mtest actually work with it.  I should see if I can still find it as I suspect the -mtest problem was a complication that wouldn't impact other classes.
Comment 2 Ross Burton 2019-05-09 14:36:56 UTC
Ah, poky-contrib:ross/py.
Comment 3 Ross Burton 2020-01-31 13:33:06 UTC
Hmm. So that branch has disappeared.

But, relatedly, poky-contrib:ross/tap contains recipes for a few different Py TAP implementations.  Specifically pychotap 1.2.1 contains a command line unittest runner I wrote so if a Python recipe's run-ptests did this before:

$ python3 -munittest foo

It can now do:

$ python3 -mpychotap foo

And it emits nice TAP format logs.  That isn't *immediately* useful for this bug but either:

1) pychotap's __main__ can serve as a template for implementing a ptest-style formatter.
2) write a TAP-to-ptest script and pipe the TAP output into it.

As TAP is gaining traction (perl and gnome use it by default), (2) is arguably a good idea.

Making python3 -mtest work is another battle: the Py test suite is sufficiently complex that you can't just 'python3 -munittest test' so using a different formatter isn't that easy.
Comment 4 Randy MacLeod 2023-04-21 18:45:42 UTC
Moved en masse from 4.2 to 4.3 by Randy.
Comment 5 Ross Burton 2023-05-04 14:49:12 UTC
The new recipe python3-unittest-automake-output (added in 961e4f3fc786715fc136fa446686972a4a95a3d5) has helpers for unittest and pytest.