Skip to content

Commit

Permalink
tests: avoid segmentation fault
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 6, 2024
1 parent d34f2f1 commit 4a5e674
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
38 changes: 21 additions & 17 deletions tests/test_rtdc_fmt_http_basin.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def test_create_basin_file_non_matching_identifier(tmp_path):
assert ds.features_basin == ["deform"]
# ...but it is actually not, since the run identifier does not match
# and therefore dclab does not allow the user to access it.
with pytest.raises(KeyError, match="deform"):
with (pytest.warns(UserWarning, match="but I cannot get its data"),
pytest.raises(KeyError, match="deform")):
_ = ds["deform"]


Expand Down Expand Up @@ -241,10 +242,10 @@ def test_trace_availability(tmp_path):
meta = src.config.as_dict(pop_filtering=True)
hw.store_metadata(meta)

ds = dclab.new_dataset(h5path)
ds.filter.manual[0] = False
ds2 = dclab.new_dataset(ds)
assert "trace" in ds2
with dclab.new_dataset(h5path) as ds:
ds.filter.manual[0] = False
with dclab.new_dataset(ds) as ds2:
assert "trace" in ds2


def test_trace_availability_invalid(tmp_path):
Expand All @@ -265,15 +266,18 @@ def test_trace_availability_invalid(tmp_path):
meta = src.config.as_dict(pop_filtering=True)
hw.store_metadata(meta)

ds = dclab.new_dataset(h5path)
ds.filter.manual[:] = False
ds.filter.manual[:2] = True
ds.apply_filter()
assert "trace" in ds
# Until a workaround is found for invalid basin URLs that return a
# status code of 200, do this test which should raise a warning,
# because `__contains__` returns True for "trace", but the trace data
# are nowhere to find.
with (pytest.warns(UserWarning, match="but I cannot get its data"),
pytest.raises(KeyError, match="trace")):
dclab.new_dataset(ds)
with dclab.new_dataset(h5path) as ds:
ds.filter.manual[:] = False
ds.filter.manual[:2] = True
ds.apply_filter()
assert "trace" in ds
# Until a workaround is found for invalid basin URLs that return a
# status code of 200, do this test which should raise a warning,
# because `__contains__` returns True for "trace", but the trace data
# are nowhere to find.
with (pytest.warns(UserWarning, match="but I cannot get its data"),
pytest.raises(KeyError, match="trace")):
_ = ds["trace"]
with (pytest.warns(UserWarning, match="but I cannot get its data"),
pytest.raises(KeyError, match="trace")):
dclab.new_dataset(ds)
3 changes: 2 additions & 1 deletion tests/test_rtdc_fmt_s3_basin.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def test_create_basin_file_non_matching_identifier(tmp_path):
assert ds.features_basin == ["deform"]
# ...but it is actually not, since the run identifier does not match
# and therefore dclab does not allow the user to access it.
with pytest.raises(KeyError, match="deform"):
with (pytest.warns(UserWarning, match="but I cannot get its data"),
pytest.raises(KeyError, match="deform")):
_ = ds["deform"]


Expand Down

0 comments on commit 4a5e674

Please sign in to comment.