Skip to content

Commit bd4fa97

Browse files
committed
skpkg: migrate tests folder
1 parent 6977f3e commit bd4fa97

File tree

2 files changed

+5
-98
lines changed

2 files changed

+5
-98
lines changed

tests/conftest.py

Lines changed: 4 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,19 @@
11
import json
22
from pathlib import Path
33

4-
import numpy as np
54
import pytest
65

7-
from diffpy.utils.diffraction_objects import DiffractionObject
8-
96

107
@pytest.fixture
118
def user_filesystem(tmp_path):
129
base_dir = Path(tmp_path)
1310
home_dir = base_dir / "home_dir"
1411
home_dir.mkdir(parents=True, exist_ok=True)
15-
cwd_dir = home_dir / "cwd_dir"
12+
cwd_dir = base_dir / "cwd_dir"
1613
cwd_dir.mkdir(parents=True, exist_ok=True)
17-
home_config_data = {
18-
"owner_name": "home_ownername",
19-
"owner_email": "[email protected]",
20-
"owner_orcid": "home_orcid",
21-
}
14+
15+
home_config_data = {"username": "home_username", "email": "[email protected]"}
2216
with open(home_dir / "diffpyconfig.json", "w") as f:
2317
json.dump(home_config_data, f)
24-
yield home_dir, cwd_dir
25-
26-
27-
@pytest.fixture
28-
def datafile():
29-
"""Fixture to dynamically load any test file."""
30-
base_path = Path(__file__).parent / "testdata" # Adjusted base path
31-
32-
def _load(filename):
33-
return base_path / filename
34-
35-
return _load
36-
37-
38-
@pytest.fixture
39-
def do_minimal():
40-
# Create an instance of DiffractionObject with empty xarray and yarray
41-
# values, and a non-empty wavelength
42-
return DiffractionObject(
43-
xarray=np.empty(0), yarray=np.empty(0), xtype="tth", wavelength=1.54
44-
)
45-
46-
47-
@pytest.fixture
48-
def do_minimal_tth():
49-
# Create an instance of DiffractionObject with non-empty xarray, yarray,
50-
# and wavelength values
51-
return DiffractionObject(
52-
wavelength=2 * np.pi,
53-
xarray=np.array([30, 60]),
54-
yarray=np.array([1, 2]),
55-
xtype="tth",
56-
)
57-
5818

59-
@pytest.fixture
60-
def do_minimal_d():
61-
# Create an instance of DiffractionObject with non-empty xarray, yarray,
62-
# and wavelength values
63-
return DiffractionObject(
64-
wavelength=1.54,
65-
xarray=np.array([1, 2]),
66-
yarray=np.array([1, 2]),
67-
xtype="d",
68-
)
69-
70-
71-
@pytest.fixture
72-
def wavelength_warning_msg():
73-
return (
74-
"No wavelength has been specified. You can continue to use the "
75-
"DiffractionObject, but some of its powerful features will not be "
76-
"available. "
77-
"To specify a wavelength, if you have "
78-
"do = DiffractionObject(xarray, yarray, 'tth'), "
79-
"you may set do.wavelength = 1.54 for a wavelength of 1.54 angstroms."
80-
)
81-
82-
83-
@pytest.fixture
84-
def invalid_q_or_d_or_wavelength_error_msg():
85-
return (
86-
"The supplied input array and wavelength will result in an "
87-
"impossible two-theta. "
88-
"Please check these values and re-instantiate the DiffractionObject "
89-
"with correct values."
90-
)
91-
92-
93-
@pytest.fixture
94-
def invalid_add_type_error_msg():
95-
return (
96-
"You may only add a DiffractionObject with another DiffractionObject "
97-
"or a scalar value. "
98-
"Please rerun by adding another DiffractionObject instance or a "
99-
"scalar value. "
100-
"e.g., my_do_1 + my_do_2 or my_do + 10 or 10 + my_do"
101-
)
102-
103-
104-
@pytest.fixture
105-
def x_values_not_equal_error_msg():
106-
return (
107-
"The two objects have different values in x arrays "
108-
"(my_do.all_arrays[:, [1, 2, 3]]). "
109-
"Please ensure the x values of the two objects are identical "
110-
"by re-instantiating the DiffractionObject with the correct x value "
111-
"inputs."
112-
)
19+
yield tmp_path

tests/test_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Unit tests for __version__.py."""
22

3-
import diffpy.utils
3+
import diffpy.utils # noqa
44

55

66
def test_package_version():

0 commit comments

Comments
 (0)