Files
romm/backend/conftest.py
T
Zach Clendenen 6915eeb26e feat(streaming): config plumbing for webstation containers
Extends the streaming container config so one container can serve many
platforms, adds the webstation protocol and subfolder keys, and warns
when a config still uses the deprecated per-emulator broker mods.

Also pins DB_NAME to a dedicated test database so the autouse
clear_database fixture can never wipe a real dev database.
2026-08-30 22:41:36 -05:00

17 lines
938 B
Python

import os
# Tests must never inherit DB_NAME from the ambient environment (e.g. a
# sourced .env pointing at a real dev/prod database) -- the autouse
# `clear_database` fixture in tests/conftest.py deletes every row in that
# database on every test. Always pin to a dedicated test database, made
# unique per pytest-xdist worker so parallel workers can't wipe rows another
# worker is mid-test with. This must run before any application module
# (config / database handlers) is imported, so the engine built at import
# time binds to the test name. As the rootdir conftest, this file is
# imported before `tests/conftest.py` (which imports those modules).
#
# The Redis cache needs no equivalent handling: under pytest it is an in-process
# FakeRedis, so each worker process is already isolated.
_xdist_worker = os.environ.get("PYTEST_XDIST_WORKER")
os.environ["DB_NAME"] = f"romm_test_{_xdist_worker}" if _xdist_worker else "romm_test"