@@ -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