def test_videos_not_created_when_png_format_set( tmp_path, manim_cfg_file, simple_scenes_path, ): """Test mp4 and gifs are not created when --format png is set""" scene_name = "SquareToCircle" command = [ sys.executable, "-m", "manim", "--renderer", "opengl", "-ql", "--media_dir", str(tmp_path), "--format", "png", simple_scenes_path, scene_name, ] out, err, exit_code = capture(command) assert exit_code == 0, err unexpected_gif_path = (tmp_path / "videos" / "simple_scenes" / "480p15" / add_version_before_extension("SquareToCircle.gif")) assert not unexpected_gif_path.exists( ), "unexpected gif file found at " + str(unexpected_gif_path, ) unexpected_mp4_path = (tmp_path / "videos" / "simple_scenes" / "480p15" / "SquareToCircle.mp4") assert not unexpected_mp4_path.exists( ), "expected mp4 file not found at " + str(unexpected_mp4_path, )
def test_custom_folders(tmp_path, manim_cfg_file, simple_scenes_path): scene_name = "SquareToCircle" command = [ sys.executable, "-m", "manim", "--renderer", "opengl", "-ql", "-s", "--media_dir", str(tmp_path), "--custom_folders", simple_scenes_path, scene_name, ] 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 = add_version_before_extension(tmp_path / "SquareToCircle.png").exists() assert exists, "--custom_folders did not produce the output file"
def test_r_flag(tmp_path, manim_cfg_file, simple_scenes_path): scene_name = "SquareToCircle" command = [ sys.executable, "-m", "manim", "--renderer", "opengl", "-ql", "-s", "--media_dir", str(tmp_path), "-r", "200,100", simple_scenes_path, scene_name, ] 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 = add_version_before_extension( tmp_path / "images" / "simple_scenes" / "SquareToCircle.png", ) assert np.asarray(Image.open(filename)).shape == (100, 200, 4)
def test_mp4_format_output(tmp_path, manim_cfg_file, simple_scenes_path): """Test only mp4 created without manim version in file name when --format mp4 is set""" scene_name = "SquareToCircle" command = [ sys.executable, "-m", "manim", "-ql", "--media_dir", str(tmp_path), "--format", "mp4", simple_scenes_path, scene_name, ] out, err, exit_code = capture(command) assert exit_code == 0, err unexpected_gif_path = ( tmp_path / "videos" / "simple_scenes" / "480p15" / add_version_before_extension("SquareToCircle.gif") ) assert not unexpected_gif_path.exists(), "unexpected gif file found at " + str( unexpected_gif_path, ) expected_mp4_path = ( tmp_path / "videos" / "simple_scenes" / "480p15" / "SquareToCircle.mp4" ) assert expected_mp4_path.exists(), "expected mp4 file not found at " + str( expected_mp4_path, )
def test_dash_as_filename(tmp_path): code = "class Test(Scene):\n def construct(self):\n self.add(Circle())\n self.wait(1)" command = [ sys.executable, "-m", "manim", "-ql", "-s", "--media_dir", str(tmp_path), "-", ] out, err, exit_code = capture(command, command_input=code) assert exit_code == 0, err exists = add_version_before_extension( (tmp_path / "images" / "-" / "Test.png")).exists() assert exists, out
def test_dash_as_filename(tmp_path): code = ("class Test(Scene):\n" " def construct(self):\n" " self.add(Circle())\n" " self.wait()") command = [ "-ql", "-s", "--media_dir", str(tmp_path), "-", ] runner = CliRunner() result = runner.invoke(main, command, input=code) assert result.exit_code == 0 exists = add_version_before_extension( tmp_path / "images" / "-" / "Test.png", ).exists() assert exists, result.output