Skip to content

Report reasons for skipped/xfailed system pytests

Tom Krizek requested to merge tkrizek/pytest-skipped-reason into main

If skip/xfail is used in pytest, it can have a reason string associated with it. When evaluating these tests, it can be useful to be able to differentiate the reason why the test was skipped/xfailed/xpassed, because there might be multiple possible reasons for that.

The extra options passed to pytest ensure that the string with the reason appears in the test summary and thus we're able to find the string with the reason in the log output.

See https://docs.pytest.org/en/7.1.x/how-to/skipping.html for more info


  • We don't use xfail in our pytests yet, so the -rxX doesn't do anything at this point (only the -rs), but I think it makes sense to use it in case we start using xfail.
  • I'm not sure whether to backport to v9_16 - pytest.skip isn't used there in any tests. But it'd be nice to have all branches behave consistently in case some tests are added in the future.

Merge request reports