pytest-runtime-xfail
Call runtime_xfail() to mark running test as xfail.
What it is and what it does
pytest-runtime-xfail fills a gap in pytest's xfail handling by allowing you to decide at runtime whether a test should be marked as expected-to-fail, while still running the test to completion. The standard pytest.xfail() call stops test execution immediately; @pytest.mark.xfail() requires the decision at collection time. This plugin's runtime_xfail fixture lets you make that decision based on conditions known only during test execution, and the test continues running so you can see both XFAIL (test failed as expected) and XPASS (test passed unexpectedly) outcomes.
The fixture works by adding an xfail marker to the test node dynamically, similar to calling request.node.add_marker(pytest.mark.xfail()) but packaged as a reusable fixture. It respects the xfail_strict configuration option, so passing tests marked with runtime_xfail will fail the test run if strict mode is enabled—useful for detecting when previously-failing tests start passing.
Use it for:
- Mark tests as xfail when a runtime condition (e.g., OS, Python version, or environment variable) indicates expected failure.
- Conditionally expect failure in a shared fixture that multiple tests depend on, based on setup-time detection.
- Track when platform-specific or version-specific test failures are resolved by using xfail_strict to catch XPASS.
- Avoid skipping tests while still recording them as expected failures when a runtime dependency or feature is unavailable.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that provides a `runtime_xfail` fixture to mark tests as expected-to-fail based on runtime conditions, allowing both XFAIL and XPASS outcomes.
Yes, if you need runtime-conditional xfail marking in pytest. The plugin solves a real gap in pytest's built-in xfail mechanisms and has no security vulnerabilities. Install friction is minimal. The aging maintenance status (308 days since last release) is a minor concern for a stable, single-purpose fixture, but the repository is not archived and the package is marked Production/Stable.
Install
pytest-runtime-xfail on PyPI
pip
pip install pytest-runtime-xfailuv
uv add pytest-runtime-xfailpoetry
poetry add pytest-runtime-xfailInstalling pytest-runtime-xfail
Before you install
Low install friction; single pytest dependency. Maintenance status is aging—last release 308 days ago—but the repository remains active and the package is marked Production/Stable.
License in practice
MIT License permits unrestricted use, modification, and distribution with only attribution and liability disclaimer required.
Quickstart
pip install pytest-runtime-xfail
import pytest
def test_something(runtime_xfail):
if runtime_condition:
runtime_xfail(reason="explanation")
assert True # test continues to run
Verify before relying
- Whether the plugin works correctly with pytest parametrization and xfail_strict in all supported Python versions.
- Performance impact when runtime_xfail is called in fixtures used by many tests.
Package facts
| License | MIT License Copyright (c) 2021 Brian Okken Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pytest |
| Maintenance | aging — 308 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 179,931/month — #10,159 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_runtime_xfail-1.1.1-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytest-checkA pytest plugin that allows tests to continue…
unclear · top 5,000 on PyPI
pytest-jira-xrayA pytest plugin that marks individual tests…
permissive · top 15,000 on PyPI
pytest-jiraA pytest plugin that links test cases to JIRA…
copyleft · top 15,000 on PyPI
pytest-rerunfailuresA pytest plugin that automatically reruns…
copyleft · top 1,000 on PyPI
pylint-pytestA Pylint plugin that suppresses false-positive…
permissive · top 15,000 on PyPI
pytest-retrypytest-retry is a pytest plugin that…
permissive · top 5,000 on PyPI
pytest-raceProvides a pytest fixture that runs test…
permissive · top 15,000 on PyPI
pytest-base-urlA pytest plugin that injects a configurable…
copyleft · top 5,000 on PyPI
pytest-subtestsAdds subTest() support to pytest, allowing…
permissive · top 5,000 on PyPI
pytest-tappytest-tap outputs test results in Test…
permissive · top 15,000 on PyPI