manim/tests/conftest.py
Naveen M K b726b40089
Update dependencies and fix tests (#1535)
* Make dependency more compatible

* Use .gitattributes to set LF by default

Signed-off-by: Naveen M K <naveen@syrusdark.website>
2021-05-22 00:18:36 +05:30

63 lines
1.6 KiB
Python

import os
import sys
import pytest
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.",
)
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 = os.path.join(os.path.dirname(__file__), "test_cli", "manim.cfg")
with open(cfgfilepath) as cfgfile:
original = cfgfile.read()
yield
with open(cfgfilepath, "w") as cfgfile:
cfgfile.write(original)
@pytest.fixture
def temp_media_dir(tmpdir):
from manim import config
orig_dir = config.media_dir
config.media_dir = str(tmpdir)
yield tmpdir
config.media_dir = orig_dir