Skip to content

Commit 2690953

Browse files
committed
adds tests for csareader.read nitems assertion
1 parent 55f3edd commit 2690953

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed
9.13 KB
Binary file not shown.
9.13 KB
Binary file not shown.

nibabel/nicom/tests/test_csareader.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
CSA2_B0 = open(pjoin(IO_DATA_PATH, 'csa2_b0.bin'), 'rb').read()
1919
CSA2_B1000 = open(pjoin(IO_DATA_PATH, 'csa2_b1000.bin'), 'rb').read()
2020
CSA2_0len = gzip.open(pjoin(IO_DATA_PATH, 'csa2_zero_len.bin.gz'), 'rb').read()
21+
CSA_STR_valid = open(pjoin(IO_DATA_PATH, 'csa_str_valid.bin'), 'rb').read()
22+
CSA_STR_200n_items = open(pjoin(IO_DATA_PATH, 'csa_str_200n_items.bin'), 'rb').read()
2123

2224

2325
@dicom_test
@@ -65,6 +67,12 @@ def test_csa_len0():
6567
assert_equal(len(tags), 44)
6668

6769

70+
def test_csa_nitem():
71+
# testing csa.read's ability to raise an error when n_items >200
72+
assert_raises(AssertionError, csa.read, CSA_STR_200n_items)
73+
assert csa.read(CSA_STR_valid)
74+
75+
6876
def test_csa_params():
6977
for csa_str in (CSA2_B0, CSA2_B1000):
7078
csa_info = csa.read(csa_str)

0 commit comments

Comments
 (0)