mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
* fixed issue * fixed tests * Update manim/renderer/cairo_renderer.py Co-authored-by: Darylgolden <darylgolden@gmail.com> * added tests * imrpoved test * fixed logic * added new test * check if the file has been outputed * added test when caching is enabled * fixed tests on windows * black * Update manim/renderer/cairo_renderer.py Co-authored-by: Naveen M K <naveen@syrusdark.website> * Update tests/assert_utils.py Co-authored-by: Naveen M K <naveen@syrusdark.website> Co-authored-by: KingWampy <9156604+WampyCakes@users.noreply.github.com> Co-authored-by: Darylgolden <darylgolden@gmail.com> Co-authored-by: Naveen M K <naveen@syrusdark.website>
25 lines
860 B
Python
25 lines
860 B
Python
import typing
|
|
from os import PathLike
|
|
from pathlib import Path
|
|
from pprint import pformat
|
|
|
|
|
|
def assert_file_exists(filepath: typing.Union[str, PathLike]) -> None:
|
|
"""Assert if filepath points to an existing file. Print all the elements (files and dir) of the parent dir of the given filepath.
|
|
|
|
This is mostly to have better assert message than using a raw assert os.path.isfile(filepath).
|
|
|
|
Parameters
|
|
----------
|
|
filepath
|
|
Filepath to check.
|
|
|
|
Raises
|
|
------
|
|
AssertionError
|
|
If filepath does not point to a file (if the file does not exist or it's a dir).
|
|
"""
|
|
path = Path(filepath)
|
|
if not path.is_file():
|
|
message = f"{path.absolute()} is not a file. Other elements in the parent directory are \n{pformat([path.name for path in list(path.parent.iterdir())])}"
|
|
raise AssertionError(message)
|