Download backend/app/tests/test_backend_settings.py from apoorvrajdev/image-captioning-api: direct link, hf CLI and curl.
- Browser
- Download file 932 Bytes
-
https://huggingface.co/spaces/apoorvrajdev/image-captioning-api/resolve/main/backend/app/tests/test_backend_settings.py
- Command line
-
hf download hf://spaces/apoorvrajdev/image-captioning-api/backend/app/tests/test_backend_settings.py
-
curl -L -o test_backend_settings.py https://huggingface.co/spaces/apoorvrajdev/image-captioning-api/resolve/main/backend/app/tests/test_backend_settings.py
932 Bytes
| """``BackendSettings`` imports cleanly and keeps its ``BACKEND_*`` field names.""" | |
| from __future__ import annotations | |
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| import pytest | |
| from app.core.config import BackendSettings | |
| BACKEND_DIR = Path(__file__).resolve().parents[2] | |
| def test_importing_the_settings_emits_no_user_warning() -> None: | |
| """A fresh interpreter, because the warning fires once, when the class is defined.""" | |
| result = subprocess.run( | |
| [sys.executable, "-W", "error::UserWarning", "-c", "import app.core.config"], | |
| cwd=BACKEND_DIR, | |
| capture_output=True, | |
| text=True, | |
| check=False, | |
| ) | |
| assert result.returncode == 0, result.stderr | |
| def test_model_version_still_reads_its_environment_variable( | |
| monkeypatch: pytest.MonkeyPatch, | |
| ) -> None: | |
| monkeypatch.setenv("BACKEND_MODEL_VERSION", "v9.9.9") | |
| assert BackendSettings().model_version == "v9.9.9" | |