mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-19 11:36:37 +08:00

* chore(deps): make Qt backend optional TODO: - [ ] Add relevant entry in CHANGELOG - [ ] Update install documentation - [ ] Make sure `manim-slides convert` can run without any Qt backend - [ ] Make sure test suite works (partially) without any Qt backend - [ ] Make sure we can import `manim_slides` without any Qt backend * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore(deps): some fixes but wip * chore(docs): update * chore(deps): support PyQt6 * chore(deps): make Qt backend optional TODO: - [ ] Add relevant entry in CHANGELOG - [ ] Update install documentation - [ ] Make sure `manim-slides convert` can run without any Qt backend - [ ] Make sure test suite works (partially) without any Qt backend - [ ] Make sure we can import `manim_slides` without any Qt backend * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore(deps): some fixes but wip * chore(docs): update * chore(deps): support PyQt6 * fix(deps): ci and docs * fix(lib): missing package * chore(ci): does it work? * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore(test): skip failing * chore(docs): update * chore(docs): update * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(docs): typo * fix(test): quit instead of shutdown --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
142 lines
3.9 KiB
Python
142 lines
3.9 KiB
Python
from pathlib import Path
|
|
from typing import Iterator, Tuple
|
|
|
|
import pytest
|
|
from click.testing import CliRunner
|
|
from qtpy.QtWidgets import QApplication
|
|
|
|
from manim_slides.present import present
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def auto_shutdown_qapp() -> Iterator[None]:
|
|
if app := QApplication.instance():
|
|
app.quit()
|
|
|
|
yield
|
|
|
|
if app := QApplication.instance():
|
|
app.quit()
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def args(slides_folder: Path) -> Iterator[Tuple[str, ...]]:
|
|
yield ("--folder", str(slides_folder), "--skip-all", "--playback-rate", "25")
|
|
|
|
|
|
def test_present(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_unexisting_slide(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["UnexistingSlide", *args])
|
|
|
|
assert results.exit_code != 0
|
|
assert "UnexistingSlide.json does not exist" in results.stdout
|
|
|
|
|
|
def test_present_full_screen(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--fullscreen", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_hide_mouse(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--hide-mouse", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_ignore_aspect_ratio(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(
|
|
present, ["BasicSlide", "--aspect-ratio", "ignore", *args]
|
|
)
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_start_at(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--start-at", "-1,-1", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_start_at_invalid(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--start-at", "0,1234", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert "Could not set presentation index to 1234"
|
|
|
|
|
|
def test_present_start_at_scene_number(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(
|
|
present, ["BasicSlide", "BasicSlide", "--start-at-scene-number", "1", *args]
|
|
)
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_start_at_slide_number(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(
|
|
present, ["BasicSlide", "--start-at-slide-number", "1", *args]
|
|
)
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_set_screen(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--screen", "0", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
@pytest.mark.skip(reason="Fails when running the whole test suite.")
|
|
def test_present_set_invalid_screen(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--screen", "999", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert "Invalid screen number 999" in results.stdout
|