detect-nondeterminism-by-repeating-tests
Use when a suite is green once but you suspect hidden nondeterminism — repeat runs under varied seed, order, parallelism and timezone, and require zero variance before trusting it.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- detect-nondeterminism-by-repeating-tests
- description
- Use when a suite is green once but you suspect hidden nondeterminism — repeat runs under varied seed, order, parallelism and timezone, and require zero variance before trusting it.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md366 B
- 参考文档TRUST.auto.yaml2.1 KB
03 SKILL.md 正文
Detect nondeterminism by repeating tests
One green run says nothing about a test that depends on time, order or randomness. Run the suite many times with varied inputs and treat any variance as a bug in the test or the code.
Procedure
- Repeat under identical conditions first — pure flakiness shows here:
pytest -q --count=10 -n auto # pytest-repeat
- Vary the seed to expose random-dependent failures:
for s in $(seq 1 20); do pytest -q --randomly-seed=$s >/dev/null 2>&1 || echo "seed $s failed"; done
pytest-randomly shuffles order and reseeds random per test.
3. Vary parallelism — races and shared state often appear only with workers:
pytest -q -n 1 && pytest -q -n 8 && pytest -q -p no:xdist
- Vary the clock — run under a shifted timezone to catch date-boundary assumptions:
TZ=Pacific/Kiritimati pytest -q tests/
- Fix per cause: seed racy timing with waits, reset session fixtures between tests, freeze
now(), make assertions order-insensitive by sorting sets before comparison. - Re-run the failing configuration until 20 consecutive clean runs, not one.
- Add the deterministic variant to CI as the default (fixed seed) and keep one shuffled job in a nightly matrix so new flakiness surfaces without blocking PRs.
Pitfalls
-p no:randomlydisables the shuffler and can hide the order dependence you meant to catch. Keep a shuffled job.- A fixed
TZ=UTCrun never catches timezone/date-arithmetic bugs. Vary it deliberately. - Running with
-p no:xdistchanges global-state behavior; test both in-process and multi-worker. - A test that only fails under load is still a bug. Do not dismiss it as "CI being slow."
Verification
for i in $(seq 20); do pytest -q --randomly-seed=$i -n auto >/dev/null 2>&1 || echo "FAIL seed $i"; done; echo done
Passes = the loop prints only done, no FAIL. Report: "20 shuffled parallel runs clean; fixed an order-dependent session fixture; nightly shuffled job added."
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.