File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Unit-suite conftest.
2+
3+ Unit tests assume OSS resolution unless they opt into EE via the shared
4+ ``enable_ee`` fixture (see ``backend/tests/conftest.py``).
5+ """
6+
7+ from collections .abc import Generator
8+
9+ import pytest
10+
11+ from onyx .utils .variable_functionality import (
12+ fetch_versioned_implementation ,
13+ global_version ,
14+ )
15+
16+
17+ @pytest .fixture (autouse = True )
18+ def _reset_leaked_ee_state () -> Generator [None , None , None ]:
19+ """Undoes EE state leaked into the process by import side effects.
20+
21+ ``set_is_ee_based_on_env_variable()`` runs at module level in ``onyx.main``
22+ and every ``background/celery/versioned_apps`` module, and flips the
23+ process-global EE flag whenever license enforcement is on (its default). A
24+ unit test whose import chain reaches one of those modules therefore silently
25+ switches every later test in the worker to EE resolution, breaking
26+ OSS-asserting tests order-dependently. Runs before ``enable_ee`` (autouse
27+ fixtures are instantiated first), so opting in still works.
28+ """
29+ if global_version .is_ee_version ():
30+ global_version .unset_ee ()
31+ # Entries resolved while the flag was flipped point at EE
32+ # implementations; drop them along with the flag.
33+ fetch_versioned_implementation .cache_clear ()
34+ yield
You can’t perform that action at this time.
0 commit comments