A community-maintained Python framework for creating mathematical animations.
Added tests for resolution flag (#2197)
Ethan Rooke0bcc380a2376
diff --git a/manim/utils/commands.py b/manim/utils/commands.pyindex 9bd00bcd6..366dd32cd 100644--- a/manim/utils/commands.py+++ b/manim/utils/commands.py@@ -27,7 +27,7 @@ def get_video_metadata(path_to_video: str) -> Dict[str, Any]:"stream=width,height,nb_frames,duration,avg_frame_rate,codec_name","-print_format","json",- path_to_video,+ str(path_to_video),]config, err, exitcode = capture(command)assert exitcode == 0, f"FFprobe error: {err}"diff --git a/tests/test_scene_rendering/opengl/test_cli_flags_opengl.py b/tests/test_scene_rendering/opengl/test_cli_flags_opengl.pyindex 0b0ae67b5..dca92fba5 100644--- a/tests/test_scene_rendering/opengl/test_cli_flags_opengl.py+++ b/tests/test_scene_rendering/opengl/test_cli_flags_opengl.py@@ -1,3 +1,4 @@+import itertoolsimport osimport sys@@ -6,7 +7,7 @@ import pytestfrom click.testing import CliRunnerfrom PIL import Image-from manim import capture+from manim import capture, get_video_metadatafrom manim.__main__ import mainfrom manim.utils.file_ops import add_version_before_extensionfrom tests.utils.video_tester import video_comparison@@ -35,6 +36,44 @@ def test_basic_scene_with_default_values(tmp_path, manim_cfg_file, simple_scenesassert exit_code == 0, err+def test_resolution_flag(tmp_path, manim_cfg_file, simple_scenes_path):+ scene_name = "NoAnimations"+ resolutions = [+ (720, 480),+ (1280, 720),+ (1920, 1080),+ (2560, 1440),+ (3840, 2160),+ (640, 480),+ (800, 600),+ ]++ separators = [";", ",", "-"]++ for (width, height), separator in itertools.product(resolutions, separators):+ command = [+ sys.executable,+ "-m",+ "manim",+ "--media_dir",+ str(tmp_path),+ "--resolution",+ f"{width}{separator}{height}",+ str(simple_scenes_path),+ scene_name,+ ]++ _, err, exit_code = capture(command)+ assert exit_code == 0, err++ path = (+ tmp_path / "videos" / "simple_scenes" / f"{height}p60" / f"{scene_name}.mp4"+ )+ meta = get_video_metadata(path)+ assert (width, height) == (meta["width"], meta["height"])++@pytest.mark.slow@video_comparison("SquareToCircleWithlFlag.json",diff --git a/tests/test_scene_rendering/simple_scenes.py b/tests/test_scene_rendering/simple_scenes.pyindex af82eefb9..a92423b3e 100644--- a/tests/test_scene_rendering/simple_scenes.py+++ b/tests/test_scene_rendering/simple_scenes.py@@ -32,7 +32,7 @@ class NoAnimations(Scene):def construct(self):dot = Dot().set_color(GREEN)self.add(dot)- self.wait(1)+ self.wait(0.1)class SceneWithStaticWait(Scene):diff --git a/tests/test_scene_rendering/test_cli_flags.py b/tests/test_scene_rendering/test_cli_flags.pyindex ef90e69a9..9abc8df21 100644--- a/tests/test_scene_rendering/test_cli_flags.py+++ b/tests/test_scene_rendering/test_cli_flags.py@@ -1,3 +1,4 @@+import itertoolsimport sysfrom pathlib import Path@@ -6,7 +7,7 @@ import pytestfrom click.testing import CliRunnerfrom PIL import Image-from manim import capture+from manim import capture, get_video_metadatafrom manim.__main__ import mainfrom manim.utils.file_ops import add_version_before_extension@@ -33,6 +34,44 @@ def test_basic_scene_with_default_values(tmp_path, manim_cfg_file, simple_scenesassert exit_code == 0, err+def test_resolution_flag(tmp_path, manim_cfg_file, simple_scenes_path):+ scene_name = "NoAnimations"+ resolutions = [+ (720, 480),+ (1280, 720),+ (1920, 1080),+ (2560, 1440),+ (3840, 2160),+ (640, 480),+ (800, 600),+ ]++ separators = [";", ",", "-"]++ for (width, height), separator in itertools.product(resolutions, separators):+ command = [+ sys.executable,+ "-m",+ "manim",+ "--media_dir",+ str(tmp_path),+ "--resolution",+ f"{width}{separator}{height}",+ str(simple_scenes_path),+ scene_name,+ ]++ _, err, exit_code = capture(command)+ assert exit_code == 0, err++ path = (+ tmp_path / "videos" / "simple_scenes" / f"{height}p60" / f"{scene_name}.mp4"+ )+ meta = get_video_metadata(path)+ assert (width, height) == (meta["width"], meta["height"])++@pytest.mark.slow@video_comparison("SquareToCircleWithlFlag.json",