Source code for cis_interface.drivers.tests.test_AsciiFileInputDriver

import nose.tools as nt
import cis_interface.drivers.tests.test_FileInputDriver as parent


[docs]class TestAsciiFileInputParam(parent.TestFileInputParam): r"""Test parameters for AsciiFileInputDriver. Attributes (in addition to the parent class): - """ def __init__(self, *args, **kwargs): super(TestAsciiFileInputParam, self).__init__(*args, **kwargs) self.driver = 'AsciiFileInputDriver' self.attr_list += ['file_kwargs', 'file'] self.args = self.args
[docs]class TestAsciiFileInputDriverNoStart(TestAsciiFileInputParam, parent.TestFileInputDriverNoStart): r"""Test runner for AsciiFileInputDriver without start. Attributes (in addition to the parent class): - """ pass
[docs]class TestAsciiFileInputDriver(TestAsciiFileInputParam, parent.TestFileInputDriver): r"""Test runner for AsciiFileInputDriver. Attributes (in addition to the parent class): - """
[docs] def assert_before_stop(self): r"""Assertions to make before stopping the driver instance.""" super(parent.TestFileInputDriver, self).assert_before_stop() elapsed = 0.0 while self.instance.n_ipc_msg == 0 and (elapsed <= self.instance.timeout): self.instance.sleep() elapsed += self.instance.sleeptime iline = 0 while True: data = self.instance.ipc_recv() if (data is None) or (data == self.instance.eof_msg): break if len(data) > 0: while self.file_lines[iline].startswith(self.comment): iline += 1 # pragma: no cover nt.assert_equal(data, self.file_lines[iline]) iline += 1 nt.assert_equal(len(self.file_lines), iline)
[docs] def assert_after_terminate(self): r"""Assertions to make after stopping the driver instance.""" super(TestAsciiFileInputDriver, self).assert_after_terminate() assert(not self.instance.file.is_open)