--- id: pytest-runtime-xfail version: "1.1.1" 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) license_treatment: permissive maintenance: aging --- # pytest-runtime-xfail — Call runtime_xfail() to mark running test as xfail. License: permissive · Maintenance: aging · Downloads: 179.9K/mo ## 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 above — 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 pip install pytest-runtime-xfail uv add pytest-runtime-xfail poetry add pytest-runtime-xfail ## Installing 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_current - Install friction: low - Maintenance: aging - Downloads: 179.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest xfail runtime decision, conditional test failure marking, pytest dynamic xfail, runtime expected failure, pytest fixture xfail, conditional xfail pytest, pytest-plugin, test-marking [View on SkillFed](https://skillfed.io/packages/pytest-runtime-xfail) · [View on PyPI](https://pypi.org/project/pytest-runtime-xfail/)