mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-06 01:27:07 +08:00
fix Windows unit test: can't delete opened temp file
This commit is contained in:
parent
fd6a568ff2
commit
bc18f64342
@ -161,18 +161,23 @@ def test_video_from_file_invalid_file_error():
|
|||||||
with tempfile.NamedTemporaryFile(suffix=".txt", delete=False) as tmp:
|
with tempfile.NamedTemporaryFile(suffix=".txt", delete=False) as tmp:
|
||||||
tmp.write(b"not a video file")
|
tmp.write(b"not a video file")
|
||||||
tmp.flush()
|
tmp.flush()
|
||||||
|
tmp_name = tmp.name
|
||||||
|
|
||||||
|
try:
|
||||||
with pytest.raises(InvalidDataError):
|
with pytest.raises(InvalidDataError):
|
||||||
video = VideoFromFile(tmp.name)
|
video = VideoFromFile(tmp_name)
|
||||||
video.get_dimensions()
|
video.get_dimensions()
|
||||||
|
finally:
|
||||||
os.unlink(tmp.name)
|
os.unlink(tmp_name)
|
||||||
|
|
||||||
|
|
||||||
def test_video_from_file_audio_only_error():
|
def test_video_from_file_audio_only_error():
|
||||||
"""ValueError raised for audio-only files"""
|
"""ValueError raised for audio-only files"""
|
||||||
with tempfile.NamedTemporaryFile(suffix=".m4a", delete=False) as tmp:
|
with tempfile.NamedTemporaryFile(suffix=".m4a", delete=False) as tmp:
|
||||||
with av.open(tmp.name, mode="w") as container:
|
tmp_name = tmp.name
|
||||||
|
|
||||||
|
try:
|
||||||
|
with av.open(tmp_name, mode="w") as container:
|
||||||
stream = container.add_stream("aac", rate=44100)
|
stream = container.add_stream("aac", rate=44100)
|
||||||
stream.sample_rate = 44100
|
stream.sample_rate = 44100
|
||||||
stream.format = "fltp"
|
stream.format = "fltp"
|
||||||
@ -190,10 +195,10 @@ def test_video_from_file_audio_only_error():
|
|||||||
container.mux(packet)
|
container.mux(packet)
|
||||||
|
|
||||||
with pytest.raises(ValueError, match="No video stream found"):
|
with pytest.raises(ValueError, match="No video stream found"):
|
||||||
video = VideoFromFile(tmp.name)
|
video = VideoFromFile(tmp_name)
|
||||||
video.get_dimensions()
|
video.get_dimensions()
|
||||||
|
finally:
|
||||||
os.unlink(tmp.name)
|
os.unlink(tmp_name)
|
||||||
|
|
||||||
|
|
||||||
def test_single_frame_video():
|
def test_single_frame_video():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user