Skip to content

Commit

Permalink
Add test for reading UTF8 annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
skjerns committed Feb 27, 2025
1 parent c283e45 commit 131bd87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Binary file added pyedflib/tests/data/test_utf8.edf
Binary file not shown.
9 changes: 9 additions & 0 deletions pyedflib/tests/test_edfreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class TestEdfReader(unittest.TestCase):
def setUpClass(cls):
# data_dir = os.path.join(os.getcwd(), 'data')
data_dir = os.path.join(os.path.dirname(__file__), 'data')
cls.edf_utf8 = os.path.join(data_dir, 'test_utf8.edf')
cls.edf_data_file = os.path.join(data_dir, 'test_generator.edf')
cls.bdf_data_file = os.path.join(data_dir, 'test_generator.bdf')
cls.bdf_data_file_datarec_2 = os.path.join(data_dir, 'test_generator_datarec_generator_2.bdf')
Expand Down Expand Up @@ -393,6 +394,14 @@ def test_EdfReader_Legacy_Header_Info(self):
for attr_name, expected_value in expected_header.items():
self.assertEqual(getattr(f, attr_name), expected_value)


def test_read_annotations_utf8(self):
"""properly test for UTF8 reading of existing file"""
with pyedflib.EdfReader(self.edf_utf8) as f:
ann_time, ann_duration, ann_text = f.readAnnotations()
self.assertEqual(ann_text[2], '中文测试八个字')


if __name__ == '__main__':
# run_module_suite(argv=sys.argv)
unittest.main()

0 comments on commit 131bd87

Please sign in to comment.