Skip to content

Commit 40a42f5

Browse files
committed
Include datafile util func in conftest
1 parent cf8597b commit 40a42f5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from importlib import resources
23
from pathlib import Path
34

45
import pytest
@@ -17,3 +18,17 @@ def user_filesystem(tmp_path):
1718
json.dump(home_config_data, f)
1819

1920
yield tmp_path
21+
22+
23+
def get_datafile(filename):
24+
return str(resources.files(__package__).joinpath("testdata/" + filename))
25+
26+
27+
@pytest.fixture
28+
def datafile():
29+
"""Fixture to dynamically load any test file."""
30+
31+
def _load(filename):
32+
return get_datafile(filename)
33+
34+
return _load

0 commit comments

Comments
 (0)