test(conftest): reset the decrypt hook and the licence-only flag that a dl run leaves set

This commit is contained in:
imSp4rky
2026-12-02 17:12:41 -07:00
parent 9622ebfdae
commit 95d36378f4
3 changed files with 13 additions and 12 deletions
+2 -4
View File
@@ -25,9 +25,8 @@ def runner() -> dl:
@pytest.mark.parametrize("cdm_only, vaults_only, best_available", [(True, False, False), (False, True, True)]) @pytest.mark.parametrize("cdm_only, vaults_only, best_available", [(True, False, False), (False, True, True)])
def test_the_resolver_takes_the_run_flags_and_becomes_the_decrypt_hook( def test_the_resolver_takes_the_run_flags_and_becomes_the_decrypt_hook(
monkeypatch: pytest.MonkeyPatch, cdm_only: bool, vaults_only: bool, best_available: bool cdm_only: bool, vaults_only: bool, best_available: bool
) -> None: ) -> None:
monkeypatch.setattr(verify, "DECRYPT_HOOK", None)
writer = create_autospec(ExportWriter, instance=True) writer = create_autospec(ExportWriter, instance=True)
cmd = runner() cmd = runner()
service = SimpleNamespace() service = SimpleNamespace()
@@ -50,8 +49,7 @@ def test_the_resolver_takes_the_run_flags_and_becomes_the_decrypt_hook(
writer.record.assert_called_once_with("title", "track", "drm") writer.record.assert_called_once_with("title", "track", "drm")
def test_no_export_gives_no_export_callback(monkeypatch: pytest.MonkeyPatch) -> None: def test_no_export_gives_no_export_callback() -> None:
monkeypatch.setattr(verify, "DECRYPT_HOOK", None)
cmd = runner() cmd = runner()
cmd.start_key_resolution(SimpleNamespace(), cdm_only=False, vaults_only=True, best_available=False, export=None) cmd.start_key_resolution(SimpleNamespace(), cdm_only=False, vaults_only=True, best_available=False, export=None)
+9 -1
View File
@@ -14,7 +14,8 @@ import pytest
from unshackle.core import binaries, console, process_exit from unshackle.core import binaries, console, process_exit
from unshackle.core import session as http_session from unshackle.core import session as http_session
from unshackle.core.config import config from unshackle.core.config import config
from unshackle.core.constants import RunCancel from unshackle.core.constants import DOWNLOAD_LICENCE_ONLY, RunCancel
from unshackle.core.drm import verify
from unshackle.core.providers import anilist from unshackle.core.providers import anilist
from unshackle.core.proxies.proxy import CATALOGUES from unshackle.core.proxies.proxy import CATALOGUES
from unshackle.core.update_checker import UpdateChecker from unshackle.core.update_checker import UpdateChecker
@@ -100,6 +101,13 @@ def no_filename_replacements(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(config, "filename_replacements", {}) monkeypatch.setattr(config, "filename_replacements", {})
@pytest.fixture(autouse=True)
def no_dl_run_state(monkeypatch: pytest.MonkeyPatch) -> None:
"""Start without the decrypt hook and the licence-only flag that a dl run of an earlier test leaves set."""
monkeypatch.setattr(verify, "DECRYPT_HOOK", None)
DOWNLOAD_LICENCE_ONLY.clear()
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def no_speed_limit(monkeypatch: pytest.MonkeyPatch) -> None: def no_speed_limit(monkeypatch: pytest.MonkeyPatch) -> None:
"""Start with no speed limit, so a limit that an earlier test locked cannot block a later one.""" """Start with no speed limit, so a limit that an earlier test locked cannot block a later one."""
+2 -7
View File
@@ -341,12 +341,7 @@ def test_the_licence_step_without_a_callback_raises_a_drm_error(tmp_path):
assert ctx.statuses == ["[red]FAILED"] # type: ignore[attr-defined] assert ctx.statuses == ["[red]FAILED"] # type: ignore[attr-defined]
@pytest.fixture def test_complete_track_decrypts_then_cleans_up(tmp_path, seen):
def no_hook(monkeypatch):
monkeypatch.setattr(verify, "DECRYPT_HOOK", None)
def test_complete_track_decrypts_then_cleans_up(tmp_path, seen, no_hook):
ctx = make_ctx(tmp_path) ctx = make_ctx(tmp_path)
ctx.save_dir.mkdir() ctx.save_dir.mkdir()
ctx.save_path.write_bytes(b"merged") ctx.save_path.write_bytes(b"merged")
@@ -363,7 +358,7 @@ def test_complete_track_decrypts_then_cleans_up(tmp_path, seen, no_hook):
assert not ctx.save_dir.exists() assert not ctx.save_dir.exists()
def test_complete_track_after_segment_decryption_only_checks(tmp_path, seen, no_hook): def test_complete_track_after_segment_decryption_only_checks(tmp_path, seen):
ctx = make_ctx(tmp_path) ctx = make_ctx(tmp_path)
ctx.save_path.write_bytes(b"merged") ctx.save_path.write_bytes(b"merged")
drm = FakeDRM(seen) drm = FakeDRM(seen)