style: apply ruff format across backend + scripts (line-length 100)
Mechanical, whole-tree `ruff format` pass — no behaviour change. Recorded in .git-blame-ignore-revs (next commit) so git blame skips it.
This commit is contained in:
@@ -4,6 +4,7 @@ No ffmpeg here: a fake Popen stands in, so the reader threads, the 1s poll loop,
|
||||
and the bounded exit wait are all exercised on any machine. These are regression tests for a real
|
||||
deadlock: stderr was opened and never read, so a chatty ffmpeg filled the ~64KB pipe, blocked on its
|
||||
next write and never exited, and `proc.wait()` never returned."""
|
||||
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
@@ -109,7 +110,9 @@ def test_a_nonzero_exit_raises_with_the_stderr_tail(fake_popen):
|
||||
_FakeProc(_FakeStream([]), _FakeStream(["Invalid data found\n"]), returncode=2)
|
||||
)
|
||||
with pytest.raises(RuntimeError, match="Invalid data found"):
|
||||
edit.run_ffmpeg(["ffmpeg"], total_s=10, on_progress=lambda _p: None, should_cancel=lambda: False)
|
||||
edit.run_ffmpeg(
|
||||
["ffmpeg"], total_s=10, on_progress=lambda _p: None, should_cancel=lambda: False
|
||||
)
|
||||
assert not proc.terminated # it exited on its own; nothing to kill
|
||||
|
||||
|
||||
@@ -119,7 +122,9 @@ def test_cancel_is_honoured_while_the_process_is_silent(fake_popen):
|
||||
proc = fake_popen(_FakeProc(_FakeStream(block=True), _FakeStream(block=True)))
|
||||
started = time.monotonic()
|
||||
with pytest.raises(edit.EditAborted):
|
||||
edit.run_ffmpeg(["ffmpeg"], total_s=10, on_progress=lambda _p: None, should_cancel=lambda: True)
|
||||
edit.run_ffmpeg(
|
||||
["ffmpeg"], total_s=10, on_progress=lambda _p: None, should_cancel=lambda: True
|
||||
)
|
||||
assert proc.terminated
|
||||
assert time.monotonic() - started < 5 # not "whenever ffmpeg next speaks"
|
||||
|
||||
@@ -153,11 +158,11 @@ def test_a_callback_exception_still_stops_the_process(fake_popen):
|
||||
def test_a_process_that_ignores_sigterm_is_killed(fake_popen):
|
||||
# `_stop`'s escalation: terminate, wait 5s, then SIGKILL. Without it a cancel could park the
|
||||
# worker thread on a process that simply refuses to go.
|
||||
proc = fake_popen(
|
||||
_FakeProc(_FakeStream(block=True), _FakeStream(block=True), wait_timeouts=1)
|
||||
)
|
||||
proc = fake_popen(_FakeProc(_FakeStream(block=True), _FakeStream(block=True), wait_timeouts=1))
|
||||
with pytest.raises(edit.EditAborted):
|
||||
edit.run_ffmpeg(["ffmpeg"], total_s=10, on_progress=lambda _p: None, should_cancel=lambda: True)
|
||||
edit.run_ffmpeg(
|
||||
["ffmpeg"], total_s=10, on_progress=lambda _p: None, should_cancel=lambda: True
|
||||
)
|
||||
assert proc.terminated and proc.killed
|
||||
|
||||
|
||||
@@ -166,7 +171,9 @@ def test_a_process_lingering_after_eof_is_stopped_and_reported(fake_popen):
|
||||
# the worker thread on `proc.wait()` forever (the old code waited with no timeout at all).
|
||||
proc = fake_popen(_FakeProc(_FakeStream([]), _FakeStream(), wait_timeouts=1))
|
||||
with pytest.raises(RuntimeError, match="did not exit"):
|
||||
edit.run_ffmpeg(["ffmpeg"], total_s=10, on_progress=lambda _p: None, should_cancel=lambda: False)
|
||||
edit.run_ffmpeg(
|
||||
["ffmpeg"], total_s=10, on_progress=lambda _p: None, should_cancel=lambda: False
|
||||
)
|
||||
assert proc.terminated
|
||||
# Two waits: the bounded grace wait that timed out, then _stop's own — never an unbounded one.
|
||||
assert proc.waits == 2
|
||||
@@ -177,6 +184,8 @@ def test_stderr_is_drained_while_the_process_runs(fake_popen):
|
||||
# real pipe, an unread one fills at ~64KB and blocks ffmpeg's next write forever.
|
||||
err = _FakeStream([f"warning {i}\n" for i in range(500)])
|
||||
fake_popen(_FakeProc(_FakeStream(["out_time_us=1000000\n"]), err))
|
||||
edit.run_ffmpeg(["ffmpeg"], total_s=10, on_progress=lambda _p: None, should_cancel=lambda: False)
|
||||
edit.run_ffmpeg(
|
||||
["ffmpeg"], total_s=10, on_progress=lambda _p: None, should_cancel=lambda: False
|
||||
)
|
||||
assert err.consumed == 500
|
||||
assert err.closed
|
||||
|
||||
Reference in New Issue
Block a user