A community-maintained Python framework for creating mathematical animations.
Fix - as filename feature (#1005)
Aathish Sivasubrahmanian9fb1a1666e8b
diff --git a/manim/_config/utils.py b/manim/_config/utils.pyindex edb7b592e..54e556214 100644--- a/manim/_config/utils.py+++ b/manim/_config/utils.py@@ -605,7 +605,9 @@ class ManimConfig(MutableMapping):if args.config_file:self.digest_file(args.config_file)- self.input_file = Path(args.file).absolute()+ # If args.file is `-`, the animation code has to be taken from STDIN, so the+ # input file path shouldn't be absolute, since that file won't be read.+ self.input_file = Path(args.file).absolute() if args.file != "-" else args.fileself.scene_names = args.scene_names if args.scene_names is not None else []self.output_file = args.output_filediff --git a/tests/test_scene_rendering/test_cli_flags.py b/tests/test_scene_rendering/test_cli_flags.pyindex e6347f496..068c66df3 100644--- a/tests/test_scene_rendering/test_cli_flags.py+++ b/tests/test_scene_rendering/test_cli_flags.py@@ -164,3 +164,22 @@ def test_custom_folders(tmp_path, manim_cfg_file, simple_scenes_path):exists = (tmp_path / "SquareToCircle.png").exists()assert exists, "--custom_folders did not produce the output file"+++def test_dash_as_filename(tmp_path):+ code = "class Test(Scene):\n def construct(self):\n self.add(Circle())\n self.wait(1)"+ command = [+ "python",+ "-m",+ "manim",+ "-ql",+ "-s",+ "--media_dir",+ str(tmp_path),+ "-",+ ]+ out, err, exit_code = capture(command, command_input=code)+ assert exit_code == 0, err+ exists = (tmp_path / "images" / "-" / "Test.png").exists()+ assert exists, outdiff --git a/tests/utils/commands.py b/tests/utils/commands.pyindex 11316d684..0cc0bec82 100644--- a/tests/utils/commands.py+++ b/tests/utils/commands.py@@ -1,13 +1,14 @@import subprocess-def capture(command, cwd=None):+def capture(command, cwd=None, command_input=None):proc = subprocess.Popen(command,stdout=subprocess.PIPE,stderr=subprocess.PIPE,+ stdin=subprocess.PIPE,encoding="utf8",cwd=cwd,)- out, err = proc.communicate()+ out, err = proc.communicate(command_input)return out, err, proc.returncode