forked from diffpy/diffpy.utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
39 lines (27 loc) · 1018 Bytes
/
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
import json
from pathlib import Path
import numpy as np
import pytest
from diffpy.utils.diffraction_objects import DiffractionObject
@pytest.fixture
def user_filesystem(tmp_path):
base_dir = Path(tmp_path)
home_dir = base_dir / "home_dir"
home_dir.mkdir(parents=True, exist_ok=True)
cwd_dir = base_dir / "cwd_dir"
cwd_dir.mkdir(parents=True, exist_ok=True)
home_config_data = {"username": "home_username", "email": "[email protected]"}
with open(home_dir / "diffpyconfig.json", "w") as f:
json.dump(home_config_data, f)
yield tmp_path
@pytest.fixture
def datafile():
"""Fixture to dynamically load any test file."""
base_path = Path(__file__).parent / "testdata" # Adjusted base path
def _load(filename):
return base_path / filename
return _load
@pytest.fixture
def do_minimal():
# Create an instance of DiffractionObject with minimal setup
return DiffractionObject(xarray=np.empty(0), yarray=np.empty(0), xtype="tth", wavelength=1.54)