mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-29 10:17:27 +02:00
[tests] Add graph-testing fixtures
Introduce test fixture to simplify graph testing in isolation.
This commit is contained in:
parent
88f9d4be39
commit
5b72131930
1 changed files with 32 additions and 0 deletions
32
tests/conftest.py
Normal file
32
tests/conftest.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
from pathlib import Path
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from meshroom.core.graph import Graph
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def graphWithIsolatedCache():
|
||||||
|
"""
|
||||||
|
Yield a Graph instance using a unique temporary cache directory.
|
||||||
|
|
||||||
|
Can be used for testing graph computation in isolation, without having to save the graph to disk.
|
||||||
|
"""
|
||||||
|
with tempfile.TemporaryDirectory() as cacheDir:
|
||||||
|
graph = Graph("")
|
||||||
|
graph.cacheDir = cacheDir
|
||||||
|
yield graph
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def graphSavedOnDisk():
|
||||||
|
"""
|
||||||
|
Yield a Graph instance saved in a unique temporary folder.
|
||||||
|
|
||||||
|
Can be used for testing graph IO and computation in isolation.
|
||||||
|
"""
|
||||||
|
with tempfile.TemporaryDirectory() as cacheDir:
|
||||||
|
graph = Graph("")
|
||||||
|
graph.save(Path(cacheDir) / "test_graph.mg")
|
||||||
|
yield graph
|
Loading…
Add table
Reference in a new issue