A community-maintained Python framework for creating mathematical animations.
Updated mobject.py, test_copy.py, and conftest.py, from os to pathlib Path (#535)
Adam Hackbarth1924ec0a7201
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.pyindex 16227bc0d..1d9b27115 100644--- a/manim/mobject/mobject.py+++ b/manim/mobject/mobject.py@@ -8,10 +8,10 @@ from functools import reduceimport copyimport itertools as itimport operator as op-import osimport randomimport sys+from pathlib import Pathfrom colour import Colorimport numpy as np@@ -199,7 +199,7 @@ class Mobject(Container):def save_image(self, name=None):self.get_image().save(- os.path.join(file_writer_config["video_dir"], (name or str(self)) + ".png")+ Path(file_writer_config["video_dir"]).joinpath((name or str(self)) + ".png"))def copy(self):diff --git a/tests/test_copy.py b/tests/test_copy.pyindex dde6a0894..a24fb1d1d 100644--- a/tests/test_copy.py+++ b/tests/test_copy.py@@ -1,4 +1,4 @@-import os+from pathlib import Pathfrom manim import Mobject, BraceLabel, file_writer_config@@ -20,11 +20,11 @@ def test_bracelabel_copy(tmp_path):# For this test to work, we need to tweak some folders temporarilyoriginal_text_dir = file_writer_config["text_dir"]original_tex_dir = file_writer_config["tex_dir"]- mediadir = os.path.join(tmp_path, "deepcopy")- file_writer_config["text_dir"] = os.path.join(mediadir, "Text")- file_writer_config["tex_dir"] = os.path.join(mediadir, "Tex")+ mediadir = Path(tmp_path) / "deepcopy"+ file_writer_config["text_dir"] = str(mediadir.joinpath("Text"))+ file_writer_config["tex_dir"] = str(mediadir.joinpath("Tex"))for el in ["text_dir", "tex_dir"]:- os.makedirs(file_writer_config[el])+ Path(file_writer_config[el]).mkdir(parents=True)# Before the refactoring of Mobject.copy(), the class BraceLabel was the# only one to have a non-trivial definition of copy. Here we test that itdiff --git a/tests/test_scene_rendering/conftest.py b/tests/test_scene_rendering/conftest.pyindex 81826ab81..0dc51dce1 100644--- a/tests/test_scene_rendering/conftest.py+++ b/tests/test_scene_rendering/conftest.py@@ -1,15 +1,15 @@import pytest-import os+from pathlib import Pathfrom manim import file_writer_config@pytest.fixturedef manim_cfg_file():- return os.path.join(os.path.dirname(__file__), "manim.cfg")+ return str(Path(__file__).parent / "manim.cfg")@pytest.fixturedef simple_scenes_path():- return os.path.join(os.path.dirname(__file__), "simple_scenes.py")+ return str(Path(__file__).parent / "simple_scenes.py")