Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fix some config options specified via `--config_file` not being respected properly (#4401)

Benjamin Hackl7e2ea86e984a
diff --git a/manim/_config/utils.py b/manim/_config/utils.py
index 31290f802..96e154d37 100644
--- a/manim/_config/utils.py
+++ b/manim/_config/utils.py
@@ -595,6 +595,7 @@ class ManimConfig(MutableMapping):
"enable_wireframe",
"force_window",
"no_latex_cleanup",
+ "dry_run",
]:
setattr(self, key, parser["CLI"].getboolean(key, fallback=False))
@@ -629,6 +630,7 @@ class ManimConfig(MutableMapping):
"background_color",
"renderer",
"window_position",
+ "preview_command",
]:
setattr(self, key, parser["CLI"].get(key, fallback="", raw=True))
diff --git a/manim/cli/render/global_options.py b/manim/cli/render/global_options.py
index 32f9547b0..209af5261 100644
--- a/manim/cli/render/global_options.py
+++ b/manim/cli/render/global_options.py
@@ -125,23 +125,23 @@ global_options = option_group(
"--force_window",
is_flag=True,
help="Force window to open when using the opengl renderer, intended for debugging as it may impact performance",
- default=False,
+ default=None,
),
option(
"--dry_run",
is_flag=True,
help="Renders animations without outputting image or video files and disables the window",
- default=False,
+ default=None,
),
option(
"--no_latex_cleanup",
is_flag=True,
help="Prevents deletion of .aux, .dvi, and .log files produced by Tex and MathTex.",
- default=False,
+ default=None,
),
option(
"--preview_command",
help="The command used to preview the output file (for example vlc for video files)",
- default="",
+ default=None,
),
)
diff --git a/tests/test_scene_rendering/test_cli_flags.py b/tests/test_scene_rendering/test_cli_flags.py
index e938ff8d2..498f1ce4a 100644
--- a/tests/test_scene_rendering/test_cli_flags.py
+++ b/tests/test_scene_rendering/test_cli_flags.py
@@ -745,3 +745,33 @@ input_file = {simple_scenes_path}
]
out, err, exit_code = capture(command, cwd=tmp_path)
assert exit_code == 0, err
+
+
+def test_dry_run_via_config_file_no_output(tmp_path, simple_scenes_path):
+ """Test that no file is created when dry_run is set to true in a config file."""
+ scene_name = "SquareToCircle"
+ config_file = tmp_path / "test_config.cfg"
+ config_file.write_text(
+ """
+[CLI]
+dry_run = true
+"""
+ )
+
+ command = [
+ sys.executable,
+ "-m",
+ "manim",
+ "--config_file",
+ str(config_file),
+ "--media_dir",
+ str(tmp_path),
+ str(simple_scenes_path),
+ scene_name,
+ ]
+ out, err, exit_code = capture(command)
+ assert exit_code == 0, err
+
+ assert not (tmp_path / "videos").exists(), "videos folder was created in dry_run"
+ assert not (tmp_path / "images").exists(), "images folder was created in dry_run"