diff --git a/qcengine/tests/test_harness_canonical.py b/qcengine/tests/test_harness_canonical.py index a3a22a73d..bdd4aaea3 100644 --- a/qcengine/tests/test_harness_canonical.py +++ b/qcengine/tests/test_harness_canonical.py @@ -148,3 +148,24 @@ def test_compute_bad_models(program, model): with pytest.raises(qcng.exceptions.InputError) as exc: ret = qcng.compute(inp, program, raise_error=True) + +def test_psi4_restarts(monkeypatch): + """ + Make sure that a random error is raised which can be restarted if psi4 fails with no error message + """ + import msgpack + # create the psi4 task + inp = AtomicInput(molecule=qcng.get_molecule("hydrogen"), driver="energy", model={"method": "hf", "basis": "6-31G"}) + def mock_execute(*args, **kwargs): + "mock the output of a failed psi4 task with missing error message" + + mock_output = { + "sucess": False, + "outfiles": {"data.msgpack": msgpack.dumps({"missing": "data"})} + } + return True, mock_output + + monkeypatch.setattr("qcengine.programs.psi4.execute", mock_execute) + + with pytest.raises(qcng.exceptions.RandomError): + _ = qcng.compute(input_data=inp, program="psi4", raise_error=True, task_config={"retries": 0}) \ No newline at end of file