manim/tests/test_scene_rendering/test_sections.py
Christopher Besch 3ce4c133dd
Introduced API for scene sections via :meth:.Scene.next_section (#2152)
* feat: added section class

* fix: fixed imports in scene.py

* feat: added section class

* fix: fixed imports in scene.py

* feat: scene file writer update; needs testing

* broken test

* fixed wrong partial movie files

* feat: added animation concatenation for sections

* fix: sections can contains None as partial movie file

* fix: correct section output file names

* fix: removed media folder

* feat: section output able to extract type

* feat: added guarantee_existence tests

* fix: touch file on windows

* fix: touch file on windows

* feat: automatically create control data with --set_test flag

* feat: added tests for sections output folder

* feat: added flag to enable sections

* feat: testing section metadata file

* feat: finished metadata tests; changed enums to be extendable

* fix: removed testing files

* fix: fixed section types

* fix: fixed outdated control data

* fix: fixed simple_scenes.py

* fix: fixed section type documentation example

* feat: added section video metadata to API

* fix: isort should stop destroying the import order for commands.py

* fix: fixed types of section metadata output

* fix: better comments

* ?

* feat: added elaborate test; switched name and type in next_section call

* feat: changed testing terminology: "config" got renamed to "movie metadata"

* fix: removed unicode lambda :<

* fix: fixed control data

* fix: removed test setter

* feat: added tutorial in the documentation

* fix: updated test control data

* fix: fixed double '.' in video tests

* fix: fixed some documentation

* fix: fixed missign JSON file in docs

* fix: implemented proposed changes

* fix: better --save_sections help

* fix: better docstrings

* fix: fixed last docstring...hopefully :>

* feat: custom section output supported

* fix: removed resolved todos

* fix: added debug for movie concatenation back

* fix: removed implemented TODO

* fix: removed doubled log

* fix: changed debug to info log

* fix: fixed log test data
2021-10-20 10:36:24 +02:00

82 lines
2 KiB
Python

import os
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),
simple_scenes_path,
scene_name,
]
_, err, exit_code = capture(command)
assert exit_code == 0, err
scene_dir = os.path.join(tmp_path, "videos", "simple_scenes", "480p15")
assert_dir_exists(scene_dir)
assert_dir_not_exists(os.path.join(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),
simple_scenes_path,
scene_name,
]
_, err, exit_code = capture(command)
assert exit_code == 0, err
scene_dir = os.path.join(tmp_path, "videos", "simple_scenes", "480p15")
assert_dir_exists(scene_dir)
assert_dir_exists(os.path.join(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),
simple_scenes_path,
scene_name,
]
_, err, exit_code = capture(command)
assert exit_code == 0, err