Debian Codegraph @

tests/test_open.py

raw
1 import gc
2 import io
3 from pathlib import Path
4
5 import av
6
7 from .common import fate_suite
8
9
10 def test_path_input() -> None:
11 path = Path(fate_suite("h264/interlaced_crop.mp4"))
12 assert isinstance(path, Path)
13
14 container = av.open(path)
15 assert type(container) is av.container.InputContainer
16
17
18 def test_str_input() -> None:
19 path = fate_suite("h264/interlaced_crop.mp4")
20 assert type(path) is str
21
22 container = av.open(path)
23 assert type(container) is av.container.InputContainer
24
25
26 def test_path_output() -> None:
27 path = Path(fate_suite("h264/interlaced_crop.mp4"))
28 assert isinstance(path, Path)
29
30 container = av.open(path, "w")
31 assert type(container) is av.container.OutputContainer
32
33
34 def test_str_output() -> None:
35 path = fate_suite("h264/interlaced_crop.mp4")
36 assert type(path) is str
37
38 container = av.open(path, "w")
39 assert type(container) is av.container.OutputContainer
40
41
42 def _container_no_close() -> None:
43 buf = io.BytesIO()
44 container = av.open(buf, mode="w", format="mp4")
45 stream = container.add_stream("mpeg4", rate=24)
46 stream.width = 320
47 stream.height = 240
48 stream.pix_fmt = "yuv420p"
49 container.start_encoding()
50
51
52 def test_container_no_close() -> None:
53 # Do not close so that container is freed through GC.
54 _container_no_close()
55 gc.collect()