mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-01 21:45:10 +00:00
fix(remote): end every remote wait of a run when the user cancels it
This commit is contained in:
@@ -13,7 +13,8 @@ from __future__ import annotations
|
||||
import pytest
|
||||
|
||||
from unshackle.commands.dl import SkippedSubtitle, download_tracks_in_passes
|
||||
from unshackle.core.constants import DOWNLOAD_CANCELLED
|
||||
from unshackle.core import process_exit
|
||||
from unshackle.core.constants import DOWNLOAD_CANCELLED, RunCancel
|
||||
from unshackle.core.tracks import Audio, Subtitle, Video
|
||||
|
||||
|
||||
@@ -95,7 +96,37 @@ def test_ctrl_c_cancels_the_tracks_still_downloading():
|
||||
)
|
||||
|
||||
assert seen == {"v": True}
|
||||
assert DOWNLOAD_CANCELLED.is_set()
|
||||
assert DOWNLOAD_CANCELLED.is_set() and RunCancel.pressed
|
||||
|
||||
|
||||
def test_a_failed_track_is_not_a_cancel_of_the_user():
|
||||
"""A child process that the cancel of the failed track ends can look like Ctrl+C."""
|
||||
|
||||
def run_one(track, _index):
|
||||
raise KeyboardInterrupt if track.id == "a" else ValueError("EXAMPLE failed")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
download_tracks_in_passes(
|
||||
[make_video(), make_audio()],
|
||||
1,
|
||||
run_one,
|
||||
skip_subtitle_errors=False,
|
||||
on_subtitle_skipped=lambda track: None,
|
||||
)
|
||||
|
||||
assert not RunCancel.pressed and not DOWNLOAD_CANCELLED.is_set()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tracks", [[make_video()], [make_subtitle("s-en", "en")]], ids=["pool", "subtitle"])
|
||||
def test_a_track_that_ends_while_the_process_stops_is_not_finished(monkeypatch, tracks):
|
||||
with pytest.raises(KeyboardInterrupt):
|
||||
download_tracks_in_passes(
|
||||
tracks,
|
||||
1,
|
||||
lambda track, _index: monkeypatch.setattr(process_exit.Stop, "signum", 15),
|
||||
skip_subtitle_errors=True,
|
||||
on_subtitle_skipped=lambda track: None,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
||||
Reference in New Issue
Block a user