/
niceSOFT
/
python3-hatchling
Обзор
Документация
Войти
/
niceSOFT
/
python3-hatchling
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tests/backend/version/source/test_env.py
35 строк
1 KB
Dimitri Papadopoulos Orfanos
Upgrade Ruff to 0.13.2 (#1890)
28 сен 2025, 21:20
Не верифицирован
28 сен 2025, 21:20
aff6f39
Код
Авторство
О чём код?
import pytest from hatch.utils.structures import EnvVars from hatchling.version.source.env import EnvSource def test_no_variable(isolation): source = EnvSource(str(isolation), {}) with pytest.raises(ValueError, match="option `variable` must be specified"): source.get_version_data() def test_variable_not_string(isolation): source = EnvSource(str(isolation), {"variable": 1}) with pytest.raises(TypeError, match="option `variable` must be a string"): source.get_version_data() def test_variable_not_available(isolation): source = EnvSource(str(isolation), {"variable": "ENV_VERSION"}) with ( EnvVars(exclude=["ENV_VERSION"]), pytest.raises(RuntimeError, match="environment variable `ENV_VERSION` is not set"), ): source.get_version_data() def test_variable_contains_version(isolation): source = EnvSource(str(isolation), {"variable": "ENV_VERSION"}) with EnvVars({"ENV_VERSION": "0.0.1"}): assert source.get_version_data()["version"] == "0.0.1"