{"library":"pytest-runtime-xfail","title":"Pytest Runtime Xfail","description":"pytest-runtime-xfail is a pytest plugin that provides a `runtime_xfail` fixture, enabling tests to be marked as 'xfail' (expected to fail) dynamically during test execution. This is particularly useful for tests that might fail under specific, conditional circumstances (e.g., different operating systems, library versions, or data states) that cannot be determined at test collection time. The current version is 1.1.1, and its release cadence is generally low, with updates as needed for bug fixes or compatibility.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pytest-runtime-xfail"],"cli":null},"imports":["def test_example(runtime_xfail):"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import platform\n\ndef test_feature_on_linux_only(runtime_xfail):\n    \"\"\"This test expects to pass on Linux, fail on others.\"\"\"\n    if platform.system() != \"Linux\":\n        runtime_xfail(f\"This feature is not supported on {platform.system()}\")\n    \n    # Simulate a test that would fail on non-Linux systems\n    assert platform.system() == \"Linux\", \"Expected to be on Linux\"\n\ndef test_conditional_bug(runtime_xfail):\n    \"\"\"This test demonstrates runtime xfail for a known bug under a condition.\"\"\"\n    # Imagine some condition based on a runtime value or environment\n    is_bug_present = True # This would be dynamically determined\n\n    if is_bug_present:\n        runtime_xfail(\"Known bug #123 causing failure under this condition\")\n    \n    # Simulate a failing assertion if the bug is present\n    assert False, \"This assertion will fail if bug is present and not xfailed\"\n","lang":"python","description":"This quickstart demonstrates how to use the `runtime_xfail` fixture within a test function. The test requests `runtime_xfail` as an argument, and then calls it conditionally. If `runtime_xfail` is called, the test will be marked as 'XFAIL' (expected to fail) with the provided reason, even if subsequent assertions fail.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}