Fix Windows CI failure in test_profile_management.py

Replace unsafe module reloading with explicit monkeypatching of constants.
This prevents potential OSError: [Errno 22] Invalid argument on Windows
during TemporaryDirectory cleanup or test execution when modules are reloaded
in a way that affects global state or file handles.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-26 03:30:39 +00:00
1 parent af32d2844c
commit ffe80e5b4d
1 file changed
+10 -3
+10 -3
View File
@@ -22,10 +22,17 @@ from seedpass.core.config_manager import ConfigManager
def test_add_and_delete_entry(monkeypatch):
with TemporaryDirectory() as tmpdir:
tmp_path = Path(tmpdir)
monkeypatch.setattr(Path, "home", lambda: tmp_path)
app_dir = tmp_path / ".seedpass"
parent_seed_file = app_dir / "parent_seed.enc"
checksum_file = app_dir / "seedpass_script_checksum.txt"
importlib.reload(constants)
importlib.reload(manager_module)
monkeypatch.setattr(constants, "APP_DIR", app_dir)
monkeypatch.setattr(constants, "PARENT_SEED_FILE", parent_seed_file)
monkeypatch.setattr(constants, "SCRIPT_CHECKSUM_FILE", checksum_file)
monkeypatch.setattr(manager_module, "APP_DIR", app_dir)
monkeypatch.setattr(manager_module, "PARENT_SEED_FILE", parent_seed_file)
monkeypatch.setattr(manager_module, "SCRIPT_CHECKSUM_FILE", checksum_file)
pm = manager_module.PasswordManager.__new__(manager_module.PasswordManager)
pm.encryption_mode = EncryptionMode.SEED_ONLY