Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fixed ``CLI.tex_template_file`` config file setting (#2992)

NotWearingPantsbf0ea2933869
diff --git a/manim/_config/utils.py b/manim/_config/utils.py
index 90210b915..1e3bea7d5 100644
--- a/manim/_config/utils.py
+++ b/manim/_config/utils.py
@@ -1543,7 +1543,7 @@ class ManimConfig(MutableMapping):
if not hasattr(self, "_tex_template") or not self._tex_template:
fn = self._d["tex_template_file"]
if fn:
- self._tex_template = TexTemplateFromFile(filename=fn)
+ self._tex_template = TexTemplateFromFile(tex_filename=fn)
else:
self._tex_template = TexTemplate()
return self._tex_template
diff --git a/tests/test_config.py b/tests/test_config.py
index c54b73877..b543e8a5e 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -7,6 +7,7 @@ from pathlib import Path
import numpy as np
from manim import WHITE, Scene, Square, Tex, Text, config, tempconfig
+from manim._config.utils import ManimConfig
from tests.assert_utils import assert_dir_exists, assert_dir_filled, assert_file_exists
@@ -210,3 +211,22 @@ def test_dry_run_with_png_format_skipped_animations():
assert config["dry_run"] is True
scene = MyScene(skip_animations=True)
scene.render()
+
+
+def test_tex_template_file(tmp_path):
+ """Test that a custom tex template file can be set from a config file."""
+ tex_file = Path(tmp_path / "my_template.tex")
+ tex_file.write_text("Hello World!")
+ tmp_cfg = tempfile.NamedTemporaryFile("w", dir=tmp_path, delete=False)
+ tmp_cfg.write(
+ f"""
+ [CLI]
+ tex_template_file = { tex_file }
+ """,
+ )
+ tmp_cfg.close()
+
+ custom_config = ManimConfig().digest_file(tmp_cfg.name)
+
+ assert Path(custom_config.tex_template_file) == tex_file
+ assert custom_config.tex_template.body == "Hello World!"