A community-maintained Python framework for creating mathematical animations.
Add test for manim cfg write
Aathish Sivasubrahmanian5c2bc1f7619b
diff --git a/tests/test_cli/test_cfg_subcmd.py b/tests/test_cli/test_cfg_subcmd.pyindex 3d55c2776..5fe56907e 100644--- a/tests/test_cli/test_cfg_subcmd.py+++ b/tests/test_cli/test_cfg_subcmd.py@@ -5,18 +5,21 @@ import shutilfrom test_cli import capturedef test_cfg_help(python_version):+ """Test if Manim successfully adds configparsers when a subcommand is invoked."""os.chdir(os.path.dirname(__file__))command = [python_version, "-m", "manim", "cfg", "--help"]out, err, exitcode = capture(command)assert exitcode == 0, f"The cfg subcommand is not working as intended."def test_cfg_show(python_version):+ """Test if the `manim cfg show` command works as intended."""command = [python_version, "-m", "manim", "cfg", "show"]out, err, exitcode = capture(command)assert exitcode == 0assert f"{os.path.sep}tests{os.path.sep}".encode("utf-8") in out, errdef test_cfg_export(python_version):+ """Test if the `manim cfg export` command works as intended."""command = [python_version, "-m", "manim", "cfg", "export", "--dir", "temp"]out, err, exitcode = capture(command)assert exitcode == 0@@ -24,3 +27,18 @@ def test_cfg_export(python_version):with open(os.path.join("temp","manim.cfg"),"r") as writtencfg:assert "sound = True" in writtencfg.read(), errshutil.rmtree("temp")++def test_cfg_write(python_version):+ """Simulate using the command `manim cfg write`"""+ command = [python_version, "-m", "manim","cfg","write","--level","cwd"]++ """As the number of config values that `manim cfg write` increases, so must the+ number of newlines and/or values written in write_cfg_sbcmd_input increase."""++ 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:+ assert "sound = False" in cfgfile.read()diff --git a/tests/test_cli/write_cfg_sbcmd_input.txt b/tests/test_cli/write_cfg_sbcmd_input.txtnew file mode 100644index 000000000..110779f7a--- /dev/null+++ b/tests/test_cli/write_cfg_sbcmd_input.txt@@ -0,0 +1,26 @@+++++++++False+++++++++++++++++