Skip to content

Commit

Permalink
Remove 6 pytest warnings with capturing wavelength
Browse files Browse the repository at this point in the history
  • Loading branch information
bobleesj committed Dec 20, 2024
1 parent 27f433d commit 5080163
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
23 changes: 23 additions & 0 deletions news/pytest-warnings-others.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* No news added

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
18 changes: 14 additions & 4 deletions tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,13 @@ def test_d_to_q(d, expected_q):
),
],
)
def test_tth_to_d(wavelength, tth, expected_d):
actual_d = tth_to_d(tth, wavelength)
def test_tth_to_d(wavelength, tth, expected_d, wavelength_warning_msg):
if wavelength is None:
with pytest.warns(UserWarning, match=re.escape(wavelength_warning_msg)):
actual_d = tth_to_d(tth, wavelength)
else:
actual_d = tth_to_d(tth, wavelength)

assert np.allclose(actual_d, expected_d)


Expand Down Expand Up @@ -221,8 +226,13 @@ def test_tth_to_d_invalid(wavelength, tth, expected_error_type, expected_error_m
),
],
)
def test_d_to_tth(wavelength, d, expected_tth):
actual_tth = d_to_tth(d, wavelength)
def test_d_to_tth(wavelength, d, expected_tth, wavelength_warning_msg):
if wavelength is None:
with pytest.warns(UserWarning, match=re.escape(wavelength_warning_msg)):
actual_tth = d_to_tth(d, wavelength)
else:
actual_tth = d_to_tth(d, wavelength)

assert np.allclose(actual_tth, expected_tth)


Expand Down

0 comments on commit 5080163

Please sign in to comment.