Commit 954d6a4f authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Fix test to correspond to error thrown

parent b3dd6eb3
......@@ -59,7 +59,8 @@ class GPIBProtocol(serial.threaded.LineReader):
try:
line = self.responses.get(timeout=timeout)
except queue.Empty:
raise RuntimeError("HPIB device at address did not respond to query:", command)
raise RuntimeError("HPIB device at address did not respond " +
"to query \"{}\"".format(command))
return line
else:
pass
......
......@@ -39,14 +39,15 @@ class TestGPIBProtocol(unittest.TestCase):
self.assertEqual(call_list[1], call(b"freq 1420 Hz\n"))
def test_command_query_no_response(self):
with self.assertRaises(RuntimeError) as context:
response = self.command_thread.protocol.command("freq?")
self.assertTrue("HPIB device at address did not respond to query \"freq?\"" in str(context.exception))
call_list = self.serial_mock.write.call_args_list
self.assertEqual(call_list[0], call(b"freq?\n"))
self.assertEqual(call_list[1], call(b"++read eoi\n"))
self.assertEqual(response, None)
def test_command_query_with_response(self):
# Put the response in the queue before asking for it
self.command_thread.protocol.responses.put("1420000000")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment