python runtime_error ai_generated partial

Flaky test detected: test_foo failed 2 times, passed 1 time

ID: python/pytest-flaky-test-rerun-failed

Also available as: JSON · Markdown · 中文
80%Fix Rate
80%Confidence
0Evidence
2024-08-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2.2 active

Root Cause

The test is flaky, meaning it sometimes passes and sometimes fails due to non-deterministic behavior, race conditions, or external dependencies.

generic

中文

测试不稳定,意味着由于非确定性行为、竞争条件或外部依赖,它有时通过有时失败。

Workarounds

  1. 85% success
    Look for: random data, time-dependent logic, network calls, shared state, order dependence. Use pytest -p no:randomly to disable random order.
  2. 90% success
    For random: random.seed(42)
    For time: freeze_time or mock datetime.now()
    For network: use responses or mock.

Dead Ends

Common approaches that don't work:

  1. 90% fail

    This masks the flakiness and can hide real bugs.

  2. 80% fail

    This stops the test from running and doesn't fix the underlying issue.