Skip to content

Commit d5d3bf7

Browse files
authored
Merge pull request #259 from bobleesj/pytest-warnings-oths
Remove 6 pytest warnings with capturing wavelength warnings
2 parents 8eaf5d7 + 5080163 commit d5d3bf7

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

news/pytest-warnings-others.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* No news added
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

tests/test_transforms.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,13 @@ def test_d_to_q(d, expected_q):
171171
),
172172
],
173173
)
174-
def test_tth_to_d(wavelength, tth, expected_d):
175-
actual_d = tth_to_d(tth, wavelength)
174+
def test_tth_to_d(wavelength, tth, expected_d, wavelength_warning_msg):
175+
if wavelength is None:
176+
with pytest.warns(UserWarning, match=re.escape(wavelength_warning_msg)):
177+
actual_d = tth_to_d(tth, wavelength)
178+
else:
179+
actual_d = tth_to_d(tth, wavelength)
180+
176181
assert np.allclose(actual_d, expected_d)
177182

178183

@@ -221,8 +226,13 @@ def test_tth_to_d_invalid(wavelength, tth, expected_error_type, expected_error_m
221226
),
222227
],
223228
)
224-
def test_d_to_tth(wavelength, d, expected_tth):
225-
actual_tth = d_to_tth(d, wavelength)
229+
def test_d_to_tth(wavelength, d, expected_tth, wavelength_warning_msg):
230+
if wavelength is None:
231+
with pytest.warns(UserWarning, match=re.escape(wavelength_warning_msg)):
232+
actual_tth = d_to_tth(d, wavelength)
233+
else:
234+
actual_tth = d_to_tth(d, wavelength)
235+
226236
assert np.allclose(actual_tth, expected_tth)
227237

228238

0 commit comments

Comments
 (0)