Skip to content

Commit 96d8db8

Browse files
Implement changes to fixtures
1 parent 67f95db commit 96d8db8

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed

tests/conftest.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pytest
77

8-
from manim import config, tempconfig
8+
import manim
99

1010

1111
def pytest_addoption(parser):
@@ -45,6 +45,20 @@ def pytest_collection_modifyitems(config, items):
4545
item.add_marker(slow_skip)
4646

4747

48+
@pytest.fixture
49+
def config():
50+
saved = manim.config.copy()
51+
# we need to return the actual config so that tests
52+
# using tempconfig pass
53+
yield manim.config
54+
manim.config.update(saved)
55+
56+
57+
@pytest.fixture
58+
def dry_run(config):
59+
config.dry_run = True
60+
61+
4862
@pytest.fixture(scope="session")
4963
def python_version():
5064
# use the same python executable as it is running currently
@@ -62,10 +76,10 @@ def reset_cfg_file():
6276

6377

6478
@pytest.fixture
65-
def using_opengl_renderer():
79+
def using_opengl_renderer(config):
6680
"""Standard fixture for running with opengl that makes tests use a standard_config.cfg with a temp dir."""
67-
with tempconfig({"renderer": "opengl"}):
68-
yield
81+
config.renderer = "opengl"
82+
yield
6983
# as a special case needed to manually revert back to cairo
7084
# due to side effects of setting the renderer
7185
config.renderer = "cairo"

tests/test_scene_rendering/conftest.py

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
import pytest
66

7-
from manim import config, tempconfig
8-
97

108
@pytest.fixture
119
def manim_cfg_file():
@@ -18,50 +16,39 @@ def simple_scenes_path():
1816

1917

2018
@pytest.fixture
21-
def using_temp_config(tmpdir):
22-
"""Standard fixture that makes tests use a standard_config.cfg with a temp dir."""
23-
with tempconfig(
24-
config.digest_file(Path(__file__).parent.parent / "standard_config.cfg"),
25-
):
26-
config.media_dir = tmpdir
27-
yield
19+
def standard_config(config):
20+
return config.digest_file(Path(__file__).parent.parent / "standard_config.cfg")
2821

2922

3023
@pytest.fixture
31-
def using_temp_opengl_config(tmpdir):
24+
def using_temp_config(tmpdir, standard_config):
3225
"""Standard fixture that makes tests use a standard_config.cfg with a temp dir."""
33-
with tempconfig(
34-
config.digest_file(Path(__file__).parent.parent / "standard_config.cfg"),
35-
):
36-
config.media_dir = tmpdir
37-
config.renderer = "opengl"
38-
yield
26+
standard_config.media_dir = tmpdir
3927

4028

4129
@pytest.fixture
42-
def disabling_caching():
43-
with tempconfig({"disable_caching": True}):
44-
yield
30+
def using_temp_opengl_config(tmpdir, standard_config, using_opengl_renderer):
31+
"""Standard fixture that makes tests use a standard_config.cfg with a temp dir."""
32+
standard_config.media_dir = tmpdir
4533

4634

4735
@pytest.fixture
48-
def infallible_scenes_path():
49-
return Path(__file__).parent / "infallible_scenes.py"
36+
def disabling_caching(config):
37+
config.disable_caching = True
5038

5139

5240
@pytest.fixture
53-
def use_opengl_renderer(enable_preview):
54-
with tempconfig({"renderer": "opengl", "preview": enable_preview}):
55-
yield
41+
def infallible_scenes_path():
42+
return Path(__file__).parent / "infallible_scenes.py"
5643

5744

5845
@pytest.fixture
59-
def force_window_config_write_to_movie():
60-
with tempconfig({"force_window": True, "write_to_movie": True}):
61-
yield
46+
def force_window_config_write_to_movie(config):
47+
config.force_window = True
48+
config.write_to_movie = True
6249

6350

6451
@pytest.fixture
65-
def force_window_config_pngs():
66-
with tempconfig({"force_window": True, "format": "png"}):
67-
yield
52+
def force_window_config_pngs(config):
53+
config.force_window = True
54+
config.format = "png"

0 commit comments

Comments
 (0)