def test_preprocess_can_stop_handling(self): jobtype = JobType(fake_assignment()) protocol = Mock(id=1) with nested( patch.object(jobtype, "preprocess_stdout_line", return_value=False), patch.object(jobtype, "format_stdout_line"), ) as (_, mocked_format): jobtype.handle_stdout_line(protocol, "stdout 1") self.assertEqual(mocked_format.call_count, 0)
def test_preprocess_replaces_output(self): jobtype = JobType(fake_assignment()) logpool.open_log(jobtype.uuid, self.create_file(), ignore_existing=True) protocol = Mock(id=2) with nested( patch.object(jobtype, "preprocess_stdout_line", return_value="foo"), patch.object(jobtype, "format_stdout_line"), ) as (_, mocked): jobtype.handle_stdout_line(protocol, "stdout 2") mocked.assert_called_with(protocol, "foo")