Skip to content

Commit e69255a

Browse files
committed
Set valid q range for test dump function
1 parent 31f3c03 commit e69255a

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

tests/test_diffraction_objects.py

+4-23
Original file line numberDiff line numberDiff line change
@@ -233,31 +233,17 @@ def test_diffraction_objects_equality(inputs1, inputs2, expected):
233233

234234

235235
def test_dump(tmp_path, mocker):
236-
x, y = np.linspace(0, 10, 11), np.linspace(0, 10, 11)
236+
x, y = np.linspace(0, 5, 6), np.linspace(0, 5, 6)
237237
directory = Path(tmp_path)
238238
file = directory / "testfile"
239239
test = Diffraction_object()
240240
test.wavelength = 1.54
241241
test.name = "test"
242242
test.scat_quantity = "x-ray"
243-
244-
with warnings.catch_warnings(record=True) as captured_warnings:
245-
# Configure the warnings system to capture all warnings
246-
warnings.simplefilter("always")
247-
248-
# Perform the method call that is expected to trigger the RuntimeWarning due to the specified wavelength
249-
test.insert_scattering_quantity(
243+
test.insert_scattering_quantity(
250244
x, y, "q", metadata={"thing1": 1, "thing2": "thing2", "package_info": {"package2": "3.4.5"}}
251-
)
252-
253-
# Verify that at least one RuntimeWarning is raised due to the arcsin error from wavelength 1.54
254-
assert any(
255-
isinstance(w.message, RuntimeWarning) for w in captured_warnings
256-
), "Expected a RuntimeWarning due to invalid arcsin input value from the wavelength set to 1.54"
257-
258-
# Ensure that exactly one warning was captured
259-
assert len(captured_warnings) == 1, "Expected exactly one warning to be captured"
260-
245+
)
246+
261247
mocker.patch("importlib.metadata.version", return_value="3.3.0")
262248

263249
with freeze_time("2012-01-14"):
@@ -275,11 +261,6 @@ def test_dump(tmp_path, mocker):
275261
"3.000000000000000000e+00 3.000000000000000000e+00\n"
276262
"4.000000000000000000e+00 4.000000000000000000e+00\n"
277263
"5.000000000000000000e+00 5.000000000000000000e+00\n"
278-
"6.000000000000000000e+00 6.000000000000000000e+00\n"
279-
"7.000000000000000000e+00 7.000000000000000000e+00\n"
280-
"8.000000000000000000e+00 8.000000000000000000e+00\n"
281-
"9.000000000000000000e+00 9.000000000000000000e+00\n"
282-
"1.000000000000000000e+01 1.000000000000000000e+01\n"
283264
)
284265

285266
assert actual == expected

0 commit comments

Comments
 (0)