forked from ManimCommunity/manim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
71 lines (56 loc) · 1.92 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from __future__ import annotations
import sys
from pathlib import Path
import pytest
from manim import config, tempconfig
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(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():
"""Standard fixture for running with opengl that makes tests use a standard_config.cfg with a temp dir."""
with tempconfig({"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"