-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_errors.py
More file actions
59 lines (51 loc) · 1.8 KB
/
test_errors.py
File metadata and controls
59 lines (51 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from pprint import pprint
import tempfile, re
from os import path
from ffmpegio.ffmpegprocess import run, PIPE
from ffmpegio import FFmpegError, caps, probe
import pytest
def test_errors():
out = run({"inputs": [], "outputs": [], "global_options": {}}, capture_log=True)
assert FFmpegError(out.stderr).ffmpeg_msg == "No ffmpeg command argument specified"
out = run(
{"inputs": [("fake.avi", None)], "outputs": [], "global_options": {}},
capture_log=True,
)
assert FFmpegError(out.stderr).ffmpeg_msg in (
"fake.avi: No such file or directory",
"Error opening input file fake.avi.\n Error opening input files: No such file or directory",
)
def test_caps_errors():
with pytest.raises(FFmpegError):
caps.bsfilter_info("bogus")
with pytest.raises(FFmpegError):
caps.muxer_info("bogus")
with pytest.raises(FFmpegError):
caps.demuxer_info("bogus")
with pytest.raises(FFmpegError):
caps.encoder_info("bogus")
with pytest.raises(FFmpegError):
caps.decoder_info("bogus")
with pytest.raises(FFmpegError):
caps.filter_info("bogus")
if __name__ == "__main__":
with tempfile.TemporaryDirectory() as tmpdirname:
out = run(
{
"inputs": [(url, {}), (srt, None)],
"outputs": [
(
out_url,
{"vf": "scale=dstw=100", "c:s": "mov_text"},
)
],
"global_options": {},
},
capture_log=True,
)
print(out.stderr)
if out.returncode:
raise FFmpegError(out.stderr)
else:
print("noerror") # print(out.returncode)
# assert str(FFmpegError(out.stderr)) == "Output file #0 does not contain any stream"