Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio tests: compare the hub source restore against the inherited source (#16236)

Daniel Han3df6e15b6e3a
diff --git a/studio/backend/tests/test_hub_source_env_reset_between_tests.py b/studio/backend/tests/test_hub_source_env_reset_between_tests.py
index 280fc2773ea..10970a3112b 100644
--- a/studio/backend/tests/test_hub_source_env_reset_between_tests.py
+++ b/studio/backend/tests/test_hub_source_env_reset_between_tests.py
@@ -6,8 +6,8 @@
``os.environ``. A test that left ModelScope selected made ``_probe_endpoint()`` answer
huggingface.co for every later test on the xdist worker, and
``test_the_probe_url_is_built_safely`` then failed for a mirror it had set itself. The two tests
-below run in order on one worker: the first writes the source the way the settings code does, the
-second fails unless conftest put it back in between.
+below run in order on one worker: the first switches to the source the process did not inherit,
+the way the settings code writes it, the second fails unless conftest put it back in between.
"""
from __future__ import annotations
@@ -20,13 +20,21 @@ from utils import hub_settings
pytestmark = pytest.mark.xdist_group("hub_source_env_reset_between_tests")
+# Read at collection, before either test runs: an operator may already have ModelScope selected.
+_INHERITED = os.environ.get(hub_settings.SOURCE_ENV)
+_OTHER = (
+ hub_settings.HUGGINGFACE
+ if hub_settings.active_source() == hub_settings.MODELSCOPE
+ else hub_settings.MODELSCOPE
+)
-def test_a_test_leaves_modelscope_selected():
+
+def test_a_test_leaves_another_source_selected():
# Assigned, not monkeypatched: apply_hub_settings() writes it the same way.
- os.environ[hub_settings.SOURCE_ENV] = hub_settings.MODELSCOPE
- assert hub_settings.active_source() == hub_settings.MODELSCOPE
+ os.environ[hub_settings.SOURCE_ENV] = _OTHER
+ assert hub_settings.active_source() == _OTHER
def test_the_next_test_starts_on_the_source_it_inherited():
- assert os.environ.get(hub_settings.SOURCE_ENV) != hub_settings.MODELSCOPE
- assert hub_settings.active_source() == hub_settings.HUGGINGFACE
+ assert os.environ.get(hub_settings.SOURCE_ENV) == _INHERITED
+ assert hub_settings.active_source() != _OTHER