def test_gpibusbcomm_query_no_question_mark(): comm = GPIBCommunicator(mock.MagicMock(), 1) comm._version = 5 comm._file.sendcmd = mock.MagicMock() # Refreshed because init makes calls comm._file.read = mock.MagicMock(return_value="answer") comm.sendcmd = mock.MagicMock() eq_(comm._query("mock"), "answer") comm.sendcmd.assert_called_with("mock") comm._file.read.assert_called_with(-1) comm._file.sendcmd.assert_has_calls([mock.call("+read")])
def test_gpibusbcomm_query(): comm = GPIBCommunicator(mock.MagicMock(), 1) comm._version = 5 comm._file.read = mock.MagicMock(return_value="answer") comm.sendcmd = mock.MagicMock() eq_(comm._query("mock?"), "answer") comm.sendcmd.assert_called_with("mock?") comm._file.read.assert_called_with(-1) comm._query("mock?", size=10) comm._file.read.assert_called_with(10)