Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

fix handling of --custom_folders, and add a test for it

leotrs30872248b247
diff --git a/manim/config/utils.py b/manim/config/utils.py
index 94ad3b3a9..1697b92a2 100644
--- a/manim/config/utils.py
+++ b/manim/config/utils.py
@@ -411,8 +411,11 @@ class ManimConfig(MutableMapping):
# Handle --custom_folders
if args.custom_folders:
- for opt in ["media_dir", "video_dir", "text_dir", "tex_dir", "log_dir"]:
+ for opt in ["media_dir", "video_dir", "images_dir", "text_dir", "tex_dir", "log_dir"]:
self[opt] = self._parser["custom_folders"].get(opt, raw=True)
+ # --media_dir overrides the deaful.cfg file
+ if hasattr(args, "media_dir"):
+ self.media_dir = args.media_dir
return self
diff --git a/tests/test_scene_rendering/test_cli_flags.py b/tests/test_scene_rendering/test_cli_flags.py
index a989596fd..00a7c2828 100644
--- a/tests/test_scene_rendering/test_cli_flags.py
+++ b/tests/test_scene_rendering/test_cli_flags.py
@@ -64,6 +64,7 @@ def test_n_flag(tmp_path, simple_scenes_path):
assert exit_code == 0, err
def test_s_flag_no_animations(tmp_path, manim_cfg_file, simple_scenes_path):
scene_name = "NoAnimations"
command = [
@@ -87,6 +88,7 @@ def test_s_flag_no_animations(tmp_path, manim_cfg_file, simple_scenes_path):
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 = [
@@ -108,3 +110,28 @@ def test_s_flag(tmp_path, manim_cfg_file, simple_scenes_path):
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_custom_folders(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),
+ "--custom_folders"
+ ]
+ out, err, exit_code = capture(command)
+ assert exit_code == 0, err
+
+ exists = (tmp_path / "videos").exists()
+ assert not exists, "--custom_folders produced a 'videos/' dir"
+
+ exists = (tmp_path / "SquareToCircle.png").exists()
+ assert exists, "--custom_folders did not produce the output file"