def _test_mode(self, mode): r = DataprocJobRunner(conf_paths=[]) with patch.multiple(r, _cleanup_cluster=mock.DEFAULT, _cleanup_job=mock.DEFAULT, _cleanup_local_tmp=mock.DEFAULT, _cleanup_logs=mock.DEFAULT, _cleanup_cloud_tmp=mock.DEFAULT) as mock_dict: r.cleanup(mode=mode) yield mock_dict
def test_python3_jupyter_notebook(self): # regression test for #1441 # this actually works on any Python platform, since we use mocks mock_stdin = Mock() mock_stdin.buffer = Mock() mock_stdout = Mock() del mock_stdout.buffer mock_stderr = Mock() del mock_stderr.buffer with patch.multiple(sys, stdin=mock_stdin, stdout=mock_stdout, stderr=mock_stderr): launcher = MRJobLauncher(args=['/path/to/script']) self.assertEqual(launcher.stdin, mock_stdin.buffer) self.assertEqual(launcher.stdout, mock_stdout) self.assertEqual(launcher.stderr, mock_stderr)