Fenliu test suite fails intermittently with SECRET_KEY placeholder errors #82
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The fenliu test suite fails non-deterministically with
RuntimeError: SECRET_KEY is set to the default placeholder and the application cannot start. Across three consecutive runs oftryke testI observed 62 failures, then 4, then 0 — all the same SECRET_KEY error.Root cause is an import-order/env race:
config.settingsis a module-level singleton that readsSECRET_KEYat import time, while several test files set it viaos.environ.setdefault(...)at module import. Depending on which test file is imported first (tryke may run files in parallel),settings.secret_keyis either the placeholder or the test value, and app-startup fixtures fail when the placeholder is still set.Reproduction: run
uv run --directory packages/fenliu tryke testa few times withoutSECRET_KEYin the environment — the failure count varies run to run. WithSECRET_KEY=... tryke testit is always green. Individual test files pass deterministically in isolation (e.g.tryke test tests/test_reblog_controls.py).