Skip to content

Commit 118a455

Browse files
committed
add tests for SqliteReader.read_all()
1 parent a62c917 commit 118a455

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

test/logformats_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,26 @@ def test_file_like_explicit_stop(self):
392392
def test_file_like_context_manager(self):
393393
pass
394394

395+
def test_read_all(self):
396+
"""
397+
testing :meth:`can.SqliteReader.read_all` with context manager and path-like object
398+
"""
399+
# create writer
400+
print("writing all messages/comments")
401+
with self.writer_constructor(self.test_file_name) as writer:
402+
self._write_all(writer)
403+
404+
# read all written messages
405+
print("reading all messages")
406+
with self.reader_constructor(self.test_file_name) as reader:
407+
read_messages = reader.read_all()
408+
409+
# check if at least the number of messages matches;
410+
self.assertEqual(len(read_messages), len(self.original_messages),
411+
"the number of written messages does not match the number of read messages")
412+
413+
self.assertMessagesEqual(read_messages)
414+
395415

396416
class TestPrinter(unittest.TestCase):
397417
"""Tests that can.Printer does not crash"""

0 commit comments

Comments
 (0)