fix(test-tools): allow edition mode markers with `run_tasks`
Tests marked saas_mode or enterprise_mode that also use run_tasks (or task_processor_mode) fail at setup with ValueError: Duplicated timeseries in CollectorRegistry. This came up while adding pytestmark = pytest.mark.enterprise_mode to release pipeline integration tests in flagsmith-private.
The cause is that the edition fixtures depend on pyfakefs's fs. pyfakefs's dynamic patcher records every module imported or reloaded while the fake filesystem is active, and removes those modules from sys.modules on teardown. task_processor_mode reloads task_processor.metrics, so the module gets evicted while its collectors stay in the global registry. The next import runs the module again and registers the same metrics a second time. Without a real site-packages, run_tasks also fails on importlib.metadata.version("flagsmith-common") under the fake filesystem.
saas_modeandenterprise_modeno longer use pyfakefs. They create the marker file in a realtmp_pathand prime the cachedis_saas/is_enterprisechecks from it under a temporarychdir.- The test's working directory isn't changed, and the checks still return
Truewhen a test also requestsfs. - Behaviour change: tests using these markers no longer get a fake filesystem implicitly. Tests that need one should request
fsexplicitly.
Tests cover both markers combined with run_tasks, and saas_mode combined with an explicit fs.
Summary by cubic
Fixes saas_mode and enterprise_mode test markers so they can be combined with run_tasks and task_processor_mode, which previously failed at setup with ValueError: Duplicated timeseries in CollectorRegistry.
The edition fixtures no longer rely on pyfakefs's fs. They now create the marker file in a real tmp_path and prime the cached is_saas/is_enterprise checks under a temporary chdir.
- Tests using these markers no longer get a fake filesystem implicitly; request
fsexplicitly if needed. - Adds tests covering both markers with
run_tasks, andsaas_modecombined with an explicitfs.