File size: 2,601 Bytes
3eedfa7 | 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | from __future__ import annotations
import sys
import pytest
from manim import capture
from tests.assert_utils import assert_dir_exists, assert_dir_not_exists
from ..utils.video_tester import video_comparison
@pytest.mark.slow
@video_comparison(
"SceneWithDisabledSections.json",
"videos/simple_scenes/480p15/SquareToCircle.mp4",
)
def test_no_sections(tmp_path, manim_cfg_file, simple_scenes_path):
scene_name = "SquareToCircle"
command = [
sys.executable,
"-m",
"manim",
"-ql",
"--media_dir",
str(tmp_path),
str(simple_scenes_path),
scene_name,
]
_, err, exit_code = capture(command)
assert exit_code == 0, err
scene_dir = tmp_path / "videos" / "simple_scenes" / "480p15"
assert_dir_exists(scene_dir)
assert_dir_not_exists(scene_dir / "sections")
@pytest.mark.slow
@video_comparison(
"SceneWithEnabledSections.json",
"videos/simple_scenes/480p15/SquareToCircle.mp4",
)
def test_sections(tmp_path, manim_cfg_file, simple_scenes_path):
scene_name = "SquareToCircle"
command = [
sys.executable,
"-m",
"manim",
"-ql",
"--save_sections",
"--media_dir",
str(tmp_path),
str(simple_scenes_path),
scene_name,
]
_, err, exit_code = capture(command)
assert exit_code == 0, err
scene_dir = tmp_path / "videos" / "simple_scenes" / "480p15"
assert_dir_exists(scene_dir)
assert_dir_exists(scene_dir / "sections")
@pytest.mark.slow
@video_comparison(
"SceneWithSections.json",
"videos/simple_scenes/480p15/SceneWithSections.mp4",
)
def test_many_sections(tmp_path, manim_cfg_file, simple_scenes_path):
scene_name = "SceneWithSections"
command = [
sys.executable,
"-m",
"manim",
"-ql",
"--save_sections",
"--media_dir",
str(tmp_path),
str(simple_scenes_path),
scene_name,
]
_, err, exit_code = capture(command)
assert exit_code == 0, err
@pytest.mark.slow
@video_comparison(
"SceneWithSkipAnimations.json",
"videos/simple_scenes/480p15/ElaborateSceneWithSections.mp4",
)
def test_skip_animations(tmp_path, manim_cfg_file, simple_scenes_path):
scene_name = "ElaborateSceneWithSections"
command = [
sys.executable,
"-m",
"manim",
"-ql",
"--save_sections",
"--media_dir",
str(tmp_path),
str(simple_scenes_path),
scene_name,
]
_, err, exit_code = capture(command)
assert exit_code == 0, err
|