Skip to content

Commit e6a006d

Browse files
authored
Merge pull request #236 from bobleesj/pytest-warnings
Refactor `test_transfor.py`: pass variables to pytest parametrize, use `conftest.py` for common error messages
2 parents da32ae3 + d962c1b commit e6a006d

File tree

2 files changed

+233
-217
lines changed

2 files changed

+233
-217
lines changed

tests/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,21 @@ def do_minimal():
4343
def do_minimal_tth():
4444
# Create an instance of DiffractionObject with non-empty xarray, yarray, and wavelength values
4545
return DiffractionObject(wavelength=2 * np.pi, xarray=np.array([30, 60]), yarray=np.array([1, 2]), xtype="tth")
46+
47+
48+
@pytest.fixture
49+
def wavelength_warning_msg():
50+
return (
51+
"No wavelength has been specified. You can continue to use the DiffractionObject, but "
52+
"some of its powerful features will not be available. "
53+
"To specify a wavelength, if you have do = DiffractionObject(xarray, yarray, 'tth'), "
54+
"you may set do.wavelength = 1.54 for a wavelength of 1.54 angstroms."
55+
)
56+
57+
58+
@pytest.fixture
59+
def invalid_q_or_d_or_wavelength_error_msg():
60+
return (
61+
"The supplied input array and wavelength will result in an impossible two-theta. "
62+
"Please check these values and re-instantiate the DiffractionObject with correct values."
63+
)

0 commit comments

Comments
 (0)