Files
manim-slides/tests/conftest.py
Jérome Eertmans d5d1513d94 chore(dev): move to Rye instead of PDM (#420)
* test: re-add opencv-python

* chore(dev): move to Rye instead of PDM

* try fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: build backend

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: string quotes?

* small fixes

* upgrade typing

* fix(ci): rye install on Windows

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix(ci): typos

* fix

* fix(ci): actually use right python version

* fix(deps): manimgl

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix docs

* another fix

* cleanup

* make sure to use trusted publisher

* chore(docs): remove PDM

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-04-18 22:12:45 +02:00

79 lines
2.0 KiB
Python

import random
import string
from collections.abc import Generator, Iterator
from pathlib import Path
import pytest
from manim_slides.config import PresentationConfig
@pytest.fixture(scope="session")
def tests_folder() -> Iterator[Path]:
yield Path(__file__).parent.resolve(strict=True)
@pytest.fixture(scope="session")
def project_folder(tests_folder: Path) -> Iterator[Path]:
yield tests_folder.parent.resolve(strict=True)
@pytest.fixture(scope="session")
def data_folder(tests_folder: Path) -> Iterator[Path]:
yield (tests_folder / "data").resolve(strict=True)
@pytest.fixture(scope="session")
def slides_folder(data_folder: Path) -> Iterator[Path]:
yield (data_folder / "slides").resolve(strict=True)
@pytest.fixture(scope="session")
def slides_file(data_folder: Path) -> Iterator[Path]:
yield (data_folder / "slides.py").resolve(strict=True)
@pytest.fixture(scope="session")
def manimgl_config(project_folder: Path) -> Iterator[Path]:
yield (project_folder / "custom_config.yml").resolve(strict=True)
@pytest.fixture(scope="session")
def video_file(data_folder: Path) -> Iterator[Path]:
yield (data_folder / "video.mp4").resolve(strict=True)
@pytest.fixture(scope="session")
def video_data_uri_file(data_folder: Path) -> Iterator[Path]:
yield (data_folder / "video_data_uri.txt").resolve(strict=True)
def random_path(
length: int = 20,
dirname: Path = Path("./media/videos/example"),
suffix: str = ".mp4",
touch: bool = False,
) -> Path:
basename = "".join(random.choices(string.ascii_letters, k=length))
filepath = dirname.joinpath(basename + suffix)
if touch:
filepath.touch()
return filepath.resolve(strict=touch)
@pytest.fixture
def paths() -> Generator[list[Path], None, None]:
random.seed(1234)
yield [random_path() for _ in range(20)]
@pytest.fixture(scope="session")
def presentation_config(
slides_folder: Path,
) -> Generator[PresentationConfig, None, None]:
yield PresentationConfig.from_file(slides_folder / "BasicSlide.json")