Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Stop changing cwd from mulitple files

Aathish Sivasubrahmanian8d4ed877dbc5
diff --git a/tests/test_cli/test_cfg_subcmd.py b/tests/test_cli/test_cfg_subcmd.py
index 27346db48..2d88f4b0d 100644
--- a/tests/test_cli/test_cfg_subcmd.py
+++ b/tests/test_cli/test_cfg_subcmd.py
@@ -30,15 +30,23 @@ def test_cfg_export(python_version):
def test_cfg_write(python_version):
"""Simulate using the command `manim cfg write`"""
+ cfgfilepath = os.path.join(os.path.dirname(__file__), "manim.cfg")
command = [python_version, "-m", "manim","cfg","write","--level","cwd"]
"""As the number of config values that `manim cfg write` can modify increases, so
must the number of newlines and/or values written in write_cfg_sbcmd_input increase."""
+ with open(cfgfilepath) as cfgfile:
+ original = cfgfile.read()
out, err, exitcode = capture(
command,
open(os.path.join(os.path.dirname(__file__), "write_cfg_sbcmd_input.txt"))
)
assert exitcode == 0, err
- with open(os.path.join(os.path.dirname(__file__), "manim.cfg")) as cfgfile:
+
+ with open(cfgfilepath,"r") as cfgfile:
assert "sound = False" in cfgfile.read()
+
+ with open(cfgfilepath,"w") as cfgfile:
+ cfgfile.write(original)
+ os.chdir(os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, os.pardir)))
\ No newline at end of file
diff --git a/tests/test_cli/test_cli.py b/tests/test_cli/test_cli.py
index ab0b7b06c..0da7fa9bc 100644
--- a/tests/test_cli/test_cli.py
+++ b/tests/test_cli/test_cli.py
@@ -15,7 +15,6 @@ def capture(command,instream=None):
def test_help(python_version):
- os.chdir(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
command = [python_version, "-m", "manim", "--help"]
out, err, exitcode = capture(command)
assert exitcode == 0, f"Manim has been installed incorrectly. Please refer to the troubleshooting section on the wiki. Error:\n{err.decode()}"