Skip to content

Commit 0078d53

Browse files
test: add dat.read() test
1 parent 415ea42 commit 0078d53

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_rawtools.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ def slice_uint16_high_variance():
2727
"""Sample uint16 slice with variable values"""
2828
return np.array([-1, 0, 100, 1000, 5000, 14830, 50321, 65535, 65536], dtype=uint16)
2929

30+
@pytest.fixture
31+
def dat_files():
32+
"""Sample .dat files' paths"""
33+
return ['tests/test_supplements/ideal_dragonfly.dat',
34+
'tests/test_supplements/ideal_nsi.dat',
35+
'tests/test_supplements/poor_dragonfly.dat',
36+
'tests/test_supplements/poor_nsi.dat']
37+
38+
3039

3140
def test_scale_uint8(slice_uint8):
3241
"""Test scaling a unsigned 8-bit integer array to own bounds."""
@@ -65,3 +74,14 @@ def test_scale_uint16_to_uint8_large_variance(slice_uint16_high_variance):
6574
scale(slice_uint16_high_variance, lbound, ubound, new_lbound, new_ubound))
6675

6776
np.testing.assert_array_equal(scaled_slice, slice_uint8)
77+
78+
def test_dat_read_both_formats(dat_files):
79+
from rawtools.dat import read
80+
# neither of these should raise any errors
81+
read(dat_files[0])
82+
read(dat_files[1])
83+
with pytest.raises(ValueError, match=r"Unable to parse"):
84+
read(dat_files[2])
85+
with pytest.raises(ValueError, match=r"Unable to parse"):
86+
read(dat_files[3])
87+

0 commit comments

Comments
 (0)