Skip to content

Commit b7ad810

Browse files
committed
catch divide by zero in dump func
1 parent 9bd388d commit b7ad810

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/test_diffraction_objects.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,16 @@ def test_dump(tmp_path, mocker):
373373
x, y = np.linspace(0, 5, 6), np.linspace(0, 5, 6)
374374
directory = Path(tmp_path)
375375
file = directory / "testfile"
376-
do = DiffractionObject(
377-
wavelength=1.54,
378-
name="test",
379-
scat_quantity="x-ray",
380-
xarray=np.array(x),
381-
yarray=np.array(y),
382-
xtype="q",
383-
metadata={"thing1": 1, "thing2": "thing2", "package_info": {"package2": "3.4.5"}},
384-
)
376+
with pytest.warns(RuntimeWarning, match="divide by zero encountered in divide"):
377+
do = DiffractionObject(
378+
wavelength=1.54,
379+
name="test",
380+
scat_quantity="x-ray",
381+
xarray=np.array(x),
382+
yarray=np.array(y),
383+
xtype="q",
384+
metadata={"thing1": 1, "thing2": "thing2", "package_info": {"package2": "3.4.5"}},
385+
)
385386
mocker.patch("importlib.metadata.version", return_value="3.3.0")
386387
with freeze_time("2012-01-14"):
387388
do.dump(file, "q")

0 commit comments

Comments
 (0)