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.

1.0 KB
Raw Blame
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0

"""Calling it before a model is selected passes None, so a None or empty model id must not raise."""

from __future__ import annotations

import logging
import sys
from pathlib import Path

_BACKEND = Path(__file__).resolve().parent.parent
if str(_BACKEND) not in sys.path:
    sys.path.insert(0, str(_BACKEND))

from utils.models.model_config import load_model_defaults  # noqa: E402


def test_none_and_empty_return_empty_without_error(caplog):
    with caplog.at_level(logging.ERROR):
        assert load_model_defaults(None) == {}  # type: ignore[arg-type]
        assert load_model_defaults("") == {}
    assert "Error loading model defaults" not in caplog.text
    assert "NoneType" not in caplog.text


def test_unknown_string_still_returns_defaults_dict():
    # The guard only short-circuits None/empty.
    result = load_model_defaults("definitely-not-a-real-model-xyz")
    assert isinstance(result, dict)