pytest-dev / pytest-dev/pytest
[RFC] Explicit mechanism for supporting xfail and skip in [third-party] plugins
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
While working on https://github.com/pytest-dev/pytest-forked/pull/34 I had to go through source code in the skipping plugin to figure out how to make pytest show xfailed tests for runs made by an external plugin. And here's my observations:
- It's undocumented how to integrate xfail with test reports from plugins.
- I learned that if you set
outcome='xfailed'andwasxfail = 'reason', pytest will show normal xfailed output in the failures and summary sections but the progress section will show the failure (Fletter instead ofX/x). - I discovered that I have to set
outcome='skipped'(along withwasxfail = 'reason'!) to make it show consistent output but I need to set it only if I discover that the test has xfail marker. Wait, what?skipped? Really? But I really ran it... - I need to inspect all the marks and their conditionals. I need to figure out if the conditional expression of any mark is true or it raises the expected exception.
- Internal implementation details leak into the public API... (at least this is how I see the need to set certain magic combination of values and do manual condition matching)
So here's what I think could be improved:
- Docs. It should be explicitly documented how to make your plugin work with xfail.
- There could be some sort of public API to make the test result xfailed. (I don't really like this so see (3))
- Implement a better xfail processing mechanism on the pytest internals side.
- Plugins should cleanly report failures and passes
- pytest should convert the test reports to have proper attributes related to xfail after receiving results from plugins
- There should be a mechanism to convey an exception that caused the failure in the test run from plugin to pytest so that it could also match it against the
raisesarg
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the skipping plugin behavior and the external-plugin integration described through pytest-forked#34, focusing on test reports, xfail markers, conditional expressions, and the raises argument. The issue proposes documentation, a public API, or internal report conversion; done would require choosing and specifying one approach that gives plugins consistent xfail and skip output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100