Source code for cis_interface.drivers.tests.test_MatInputDriver

import os
import numpy as np
from scipy.io import savemat
from cis_interface.backwards import pickle
import cis_interface.drivers.tests.test_IODriver as parent


[docs]class TestMatInputDriver(parent.TestIODriver): r"""Test runner for MatInputDriver. Attributes (in addition to parent class's): filepath (str): Full path to test file. """ def __init__(self, *args, **kwargs): super(TestMatInputDriver, self).__init__(*args, **kwargs) self.driver = 'MatInputDriver' self.filepath = os.path.abspath('mat_input.mat') self.args = self.filepath
[docs] def setup(self): r"""Create a driver instance and start the driver.""" with open(self.filepath, 'wb') as fd: savemat(fd, self.data_dict) super(TestMatInputDriver, self).setup()
[docs] def teardown(self): r"""Remove the instance, stoppping it.""" super(TestMatInputDriver, self).teardown() if os.path.isfile(self.filepath): os.remove(self.filepath)
[docs] def assert_before_stop(self): r"""Assertions to make before stopping the driver instance.""" super(TestMatInputDriver, self).assert_before_stop() msg_recv = self.instance.recv_wait_nolimit() assert(msg_recv) dat_recv = pickle.loads(msg_recv) for k in self.data_dict.keys(): np.testing.assert_array_equal(dat_recv[k], self.data_dict[k])
[docs] def assert_after_terminate(self): r"""Assertions to make after stopping the driver instance.""" super(TestMatInputDriver, self).assert_after_terminate() assert(self.instance.fd is None)
[docs] def test_send_recv(self): r"""Test sending/receiving small message.""" pass
[docs] def test_send_recv_nolimit(self): r"""Test sending/receiving large message.""" pass