diff --git a/nptdms/test/test_tdms_file.py b/nptdms/test/test_tdms_file.py index 8be099b..e4b1cc6 100644 --- a/nptdms/test/test_tdms_file.py +++ b/nptdms/test/test_tdms_file.py @@ -482,6 +482,20 @@ def test_read_with_index_file(test_file, expected_data): compare_arrays(channel_obj.data, expected_channel_data) +def test_read_index_file_only(): + """ Test reading the index file directly + """ + test_file, expected_data = scenarios.single_segment_with_two_channels().values + with test_file.get_tempfile_with_index() as tdms_file_path: + with TdmsFile.open(tdms_file_path + "_index") as tdms_file: + for ((group, channel), expected_channel_data) in expected_data.items(): + channel_obj = tdms_file[group][channel] + assert len(channel_obj) == len(expected_channel_data) + with pytest.raises(RuntimeError) as exc_info: + channel_obj[:] + assert "Data cannot be read from index file only" in str(exc_info.value) + + @pytest.mark.skipif(sys.version_info < (3, 4), reason="pathlib only available in stdlib since 3.4") def test_read_file_passed_as_pathlib_path(): """ Test reading a file when using a pathlib Path object