1313from sbp .client .loggers .base_logger import LogIterator
1414from sbp .client .loggers .json_logger import JSONLogIterator , MultiJSONLogIterator
1515from sbp .client .loggers .pickle_logger import PickleLogIterator
16+ from sbp .client .loggers .device_iterator import DeviceIterator
1617from sbp .logging import SBP_MSG_PRINT
18+ from sbp .acquisition import SBP_MSG_ACQ_RESULT , MsgAcqResult
1719from sbp .table import _SBP_TABLE , dispatch
1820from sbp .table import InvalidSBPMessageType
21+ from sbp .client .handler import Handler
1922import pytest
2023import warnings
2124
@@ -151,3 +154,22 @@ def test_msg_print():
151154 assert len (w ) == 1
152155 assert issubclass (w [0 ].category , RuntimeWarning )
153156 assert str (w [0 ].message ).startswith ('Bad message parsing for line' )
157+
158+ def test_device_iterator ():
159+ """
160+ device iterator sanity tests.
161+ """
162+ log_datafile = "data/one_msg.bin"
163+ handle = open (log_datafile , 'r' )
164+ myhandler = Handler (handle .read , None , verbose = True )
165+ mydevice_iterator = DeviceIterator (myhandler , 0.5 )
166+ myhandler .start ()
167+ for delta , timestamp , msg in mydevice_iterator :
168+ assert delta > 0
169+ assert timestamp > 0
170+ assert type (msg ) == MsgAcqResult
171+ # warnings.simplefilter("always")
172+ # Check for warnings.
173+ #assert len(w) == 1
174+ #assert issubclass(w[0].category, RuntimeWarning)
175+ #assert str(w[0].message).startswith('Bad message parsing for line')
0 commit comments