whisper-dictation/tests/test_config.py

21 lines
798 B
Python

import sys, os, importlib
def test_app_dir_dev_mode(monkeypatch, tmp_path):
"""In dev mode, _app_dir() returns the repo root (two levels above config.py)."""
monkeypatch.delattr(sys, "frozen", raising=False)
from whisper_app import config
importlib.reload(config)
result = config._app_dir()
assert os.path.isdir(result)
assert os.path.basename(result) != "whisper_app"
def test_app_dir_frozen_mode(monkeypatch, tmp_path):
"""In frozen mode, _app_dir() returns dirname(sys.executable)."""
monkeypatch.setattr(sys, "frozen", True, raising=False)
monkeypatch.setattr(sys, "executable", str(tmp_path / "whisper-dictation.exe"))
from whisper_app import config
importlib.reload(config)
assert config._app_dir() == str(tmp_path)