mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
* Allow python 3.13
* Specify scipy more strictly
* try using 3rd-party audioop package
* debug: wrap context generation in try-block
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* remove audioop-lts, update dependencies
* add wrapt pre-release (wheels!)
* update lockfile
* CI, windows: try installing all tinytex packages at once
* tmp: verbosity of pytest
* tmp: pass -n 0 for testing
* tmp: disable pytest-xdist
* remove deprecated poetry installer option
* try running tests via uv-provided env
* tmp: run -> run --no-project
* try --full-trace
* try running tests via python -v ...
* tmp: test import of suspicious modules
* test click/cloup
* ci: back to poetry
* ci: disable pytest plugins altogether
* update lockfile
* ci: upgrade pytest
* remove all flags from pytest call
* ci: move conftest, temporarily disable test header
* fix test fixture
* try with more recent version of pytest-xdist
* loadfile -> loadscope
* explicitly test pytest for non-manim module
* some proper tests
* only keep fixtures in new conftest.py
* remove all non-necessary fixtures
* try a literal try/except in fixture file
* simplify tests further
* try and explicitly trigger non-silent errors
* Revert "try and explicitly trigger non-silent errors"
This reverts commit 35b862d483.
* more pytest debug output
* test whether manim can be imported correctly
* test with upgraded numpy
* revert all sorts of debug changes, attempt clean pytest run
* fix whitespace
* pre-commit hooks
* apply config fixture to render tests
* let config fixture ensure renderer is set to cairo
* update doctests for numpy>=2.0
* missed some
* upgrade required numpy version, revert separate treatment of numpy in ci
* upgraded moderngl-window to latest
* more delicate versioning of numpy dependency
---------
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
127 lines
3.3 KiB
Python
127 lines
3.3 KiB
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import cairo
|
|
import moderngl
|
|
import pytest
|
|
|
|
import manim
|
|
|
|
|
|
def pytest_report_header(config):
|
|
try:
|
|
ctx = moderngl.create_standalone_context()
|
|
info = ctx.info
|
|
ctx.release()
|
|
except Exception as e:
|
|
raise Exception("Error while creating moderngl context") from e
|
|
|
|
return (
|
|
f"\nCairo Version: {cairo.cairo_version()}",
|
|
"\nOpenGL information",
|
|
"------------------",
|
|
f"vendor: {info['GL_VENDOR'].strip()}",
|
|
f"renderer: {info['GL_RENDERER'].strip()}",
|
|
f"version: {info['GL_VERSION'].strip()}\n",
|
|
)
|
|
|
|
|
|
def pytest_addoption(parser):
|
|
parser.addoption(
|
|
"--skip_slow",
|
|
action="store_true",
|
|
default=False,
|
|
help="Will skip all the slow marked tests. Slow tests are arbitrarily marked as such.",
|
|
)
|
|
parser.addoption(
|
|
"--show_diff",
|
|
action="store_true",
|
|
default=False,
|
|
help="Will show a visual comparison if a graphical unit test fails.",
|
|
)
|
|
parser.addoption(
|
|
"--set_test",
|
|
action="store_true",
|
|
default=False,
|
|
help="Will create the control data for EACH running tests. ",
|
|
)
|
|
|
|
|
|
def pytest_configure(config):
|
|
config.addinivalue_line("markers", "skip_end_to_end: mark test as end_to_end test")
|
|
|
|
|
|
def pytest_collection_modifyitems(config, items):
|
|
if not config.getoption("--skip_slow"):
|
|
return
|
|
else:
|
|
slow_skip = pytest.mark.skip(
|
|
reason="Slow test skipped due to --disable_slow flag.",
|
|
)
|
|
for item in items:
|
|
if "slow" in item.keywords:
|
|
item.add_marker(slow_skip)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def temp_media_dir(tmpdir, monkeypatch, request):
|
|
if isinstance(request.node, pytest.DoctestItem):
|
|
monkeypatch.chdir(tmpdir)
|
|
yield tmpdir
|
|
else:
|
|
with manim.tempconfig({"media_dir": str(tmpdir)}):
|
|
assert manim.config.media_dir == str(tmpdir)
|
|
yield tmpdir
|
|
|
|
|
|
@pytest.fixture
|
|
def manim_caplog(caplog):
|
|
logger = logging.getLogger("manim")
|
|
logger.propagate = True
|
|
caplog.set_level(logging.INFO, logger="manim")
|
|
yield caplog
|
|
logger.propagate = False
|
|
|
|
|
|
@pytest.fixture
|
|
def config():
|
|
saved = manim.config.copy()
|
|
manim.config.renderer = "cairo"
|
|
# we need to return the actual config so that tests
|
|
# using tempconfig pass
|
|
yield manim.config
|
|
manim.config.update(saved)
|
|
|
|
|
|
@pytest.fixture
|
|
def dry_run(config):
|
|
config.dry_run = True
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def python_version():
|
|
# use the same python executable as it is running currently
|
|
# rather than randomly calling using python or python3, which
|
|
# may create problems.
|
|
return sys.executable
|
|
|
|
|
|
@pytest.fixture
|
|
def reset_cfg_file():
|
|
cfgfilepath = Path(__file__).parent / "test_cli" / "manim.cfg"
|
|
original = cfgfilepath.read_text()
|
|
yield
|
|
cfgfilepath.write_text(original)
|
|
|
|
|
|
@pytest.fixture
|
|
def using_opengl_renderer(config):
|
|
"""Standard fixture for running with opengl that makes tests use a standard_config.cfg with a temp dir."""
|
|
config.renderer = "opengl"
|
|
yield
|
|
# as a special case needed to manually revert back to cairo
|
|
# due to side effects of setting the renderer
|
|
config.renderer = "cairo"
|