Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Merge branch 'master' into test-r-flag

leotrsa3d4258e5d66
diff --cc tests/test_scene_rendering/test_cli_flags.py
index f65fece88,934445f13..6e4c634ed
--- a/tests/test_scene_rendering/test_cli_flags.py
+++ b/tests/test_scene_rendering/test_cli_flags.py
@@@ -1,5 -1,5 +1,6 @@@
+import matplotlib.pyplot as plt
import pytest
+ from pathlib import Path
from ..utils.video_tester import *
@@@ -65,28 -64,49 +66,78 @@@ def test_n_flag(tmp_path, simple_scenes
assert exit_code == 0, err
+ def test_s_flag_no_animations(tmp_path, manim_cfg_file, simple_scenes_path):
+ scene_name = "NoAnimations"
+ command = [
+ "python",
+ "-m",
+ "manim",
+ simple_scenes_path,
+ scene_name,
+ "-ql",
+ "-s",
+ "--media_dir",
+ str(tmp_path),
+ ]
+ out, err, exit_code = capture(command)
+ assert exit_code == 0, err
+
+ print(list((tmp_path / "images" / "simple_scenes").iterdir()))
+
+ is_empty = not any((tmp_path / "videos").iterdir())
+ assert is_empty, "running manim with -s flag rendered a video"
+
+ is_empty = not any((tmp_path / "images" / "simple_scenes").iterdir())
+ assert not is_empty, "running manim with -s flag did not render an image"
+
+
+ def test_s_flag(tmp_path, manim_cfg_file, simple_scenes_path):
+ scene_name = "SquareToCircle"
+ command = [
+ "python",
+ "-m",
+ "manim",
+ simple_scenes_path,
+ scene_name,
+ "-ql",
+ "-s",
+ "--media_dir",
+ str(tmp_path),
+ ]
+ out, err, exit_code = capture(command)
+ assert exit_code == 0, err
+
+ is_empty = not any((tmp_path / "videos").iterdir())
+ assert is_empty, "running manim with -s flag rendered a video"
+
+ is_empty = not any((tmp_path / "images" / "simple_scenes").iterdir())
+ assert not is_empty, "running manim with -s flag did not render an image"
++
++
+def test_r_flag(tmp_path, manim_cfg_file, simple_scenes_path):
+ scene_name = "SquareToCircle"
+ command = [
+ "python",
+ "-m",
+ "manim",
+ simple_scenes_path,
+ scene_name,
+ "-ql",
+ "-s",
+ "--media_dir",
+ str(tmp_path),
+ "-r",
+ "100, 200",
+ ]
+ out, err, exit_code = capture(command)
+ assert exit_code == 0, err
+
+ is_not_empty = any((tmp_path / "images").iterdir())
+ assert is_not_empty, "running manim with -s, -r flag did not render a file"
+
+ filename = tmp_path / "images" / "simple_scenes" / "SquareToCircle.png"
+ image = plt.imread(filename)
+ assert image.shape == (100, 200, 4)