コード例 #1
0
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")])
コード例 #2
0
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")])
コード例 #3
0
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)
コード例 #4
0
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)