|
| 1 | +import subprocess |
| 2 | +import os |
| 3 | +from shutil import rmtree |
| 4 | +import pytest |
| 5 | + |
| 6 | + |
| 7 | +def capture(command): |
| 8 | + proc = subprocess.Popen(command, |
| 9 | + stdout=subprocess.PIPE, |
| 10 | + stderr=subprocess.PIPE, |
| 11 | + ) |
| 12 | + out, err = proc.communicate() |
| 13 | + return out, err, proc.returncode |
| 14 | + |
| 15 | + |
| 16 | +def test_help(python_version): |
| 17 | + command = [python_version, "-m", "manim", "--help"] |
| 18 | + out, err, exitcode = capture(command) |
| 19 | + assert exitcode == 0, f"Manim has been installed incorrectly. Please refer to the troubleshooting section on the wiki. Error: {err}" |
| 20 | + |
| 21 | + |
| 22 | +@pytest.mark.skip_end_to_end |
| 23 | +def test_basicScene(python_version): |
| 24 | + """ Simulate SquareToCircle. The cache will be saved in tests_caches/media_temp (temporary directory). This is mainly intended to test the partial-movies process. """ |
| 25 | + path_basic_scene = os.path.join("tests", "tests_data", "basic_scenes.py") |
| 26 | + path_output = os.path.join("tests", "tests_cache", "media_temp") |
| 27 | + command = [python_version, "-m", "manim", path_basic_scene, |
| 28 | + "SquareToCircle", "-l", "--media_dir", path_output] |
| 29 | + out, err, exitcode = capture(command) |
| 30 | + assert exitcode == 0, err |
| 31 | + assert os.path.exists(os.path.join( |
| 32 | + path_output, "videos", "basic_scenes", "480p15", "SquareToCircle.mp4")), err |
| 33 | + rmtree(path_output) |
| 34 | + |
| 35 | +@pytest.mark.skip_end_to_end |
| 36 | +def test_WriteStuff(python_version): |
| 37 | + """This is mainly intended to test the caching process of the tex objects""" |
| 38 | + path_basic_scene = os.path.join("tests", "tests_data", "basic_scenes.py") |
| 39 | + path_output = os.path.join("tests", "tests_cache", "media_temp") |
| 40 | + command = [python_version, "-m", "manim", path_basic_scene, |
| 41 | + "WriteStuff", "-l", "--media_dir", path_output] |
| 42 | + out, err, exitcode = capture(command) |
| 43 | + assert exitcode == 0, err |
| 44 | + assert os.path.exists(os.path.join( |
| 45 | + path_output, "videos", "basic_scenes", "480p15", "WriteStuff.mp4")), err |
| 46 | + rmtree(path_output) |
0 commit comments