mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
* Migrate more `os.path` to `pathlib` in tests * Convert test fixtures to pathlib * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix mypy errors in tests * migrate another pathlib instance Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
31 lines
858 B
Python
31 lines
858 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from manim import *
|
|
from tests.assert_utils import assert_dir_exists, assert_file_not_exists
|
|
from tests.utils.video_tester import *
|
|
|
|
|
|
def test_guarantee_existence(tmp_path: Path):
|
|
test_dir = tmp_path / "test"
|
|
guarantee_existence(test_dir)
|
|
# test if file dir got created
|
|
assert_dir_exists(test_dir)
|
|
with (test_dir / "test.txt").open("x") as f:
|
|
pass
|
|
# test if file didn't get deleted
|
|
guarantee_existence(test_dir)
|
|
|
|
|
|
def test_guarantee_empty_existence(tmp_path: Path):
|
|
test_dir = tmp_path / "test"
|
|
test_dir.mkdir()
|
|
with (test_dir / "test.txt").open("x"):
|
|
pass
|
|
|
|
guarantee_empty_existence(test_dir)
|
|
# test if dir got created
|
|
assert_dir_exists(test_dir)
|
|
# test if dir got cleaned
|
|
assert_file_not_exists(test_dir / "test.txt")
|