def test_store_traces(self, mock_log): dut = Dut("test") self.assertTrue(dut.store_traces) dut.store_traces = False self.assertFalse(dut.store_traces) dut.store_traces = True self.assertTrue(dut.store_traces)
def test_read_reasponse(self, mock_log): dut = Dut("test") with mock.patch.object(dut, "readline") as mocked_readline: mocked_readline.side_effect = ["retcode: 0", RuntimeError, "retcode: 0", "test"] resp = dut._read_response() self.assertTrue(isinstance(resp, CliResponse)) self.assertEqual(dut._read_response(), -1) prior_len = len(dut.traces) dut.store_traces = False dut._read_response() self.assertEqual(len(dut.traces), prior_len) dut.store_traces = True resp = dut._read_response() self.assertEqual(len(dut.traces), prior_len + 1) self.assertIsNone(resp)