

def test_opt_failed(self):
    shutil.copyfile(os.path.join(test_dir, 'hf_opt_failed.qcinp'), os.path.join(scr_dir, 'hf_opt_failed.qcinp'))
    shutil.copyfile(os.path.join(test_dir, 'hf_opt_failed.qcout'), os.path.join(scr_dir, 'hf_opt_failed.qcout'))
    h = QChemErrorHandler(input_file='hf_opt_failed.qcinp', output_file='hf_opt_failed.qcout')
    has_error = h.check()
    self.assertTrue(has_error)
    d = h.correct()
    self.assertEqual(d, {
        'errors': ['Geometry optimization failed'],
        'actions': ['increase_iter'],
    })
    with open(os.path.join(test_dir, 'hf_opt_failed_tried_0.qcinp')) as f:
        ref = [line.strip() for line in f.readlines()]
    with open(os.path.join(scr_dir, 'hf_opt_failed.qcinp')) as f:
        ans = [line.strip() for line in f.readlines()]
    self.assertEqual(ref, ans)
    shutil.copyfile(os.path.join(test_dir, 'hf_opt_failed_tried_0.qcinp'), os.path.join(scr_dir, 'hf_opt_failed_tried_0.qcinp'))
    shutil.copyfile(os.path.join(test_dir, 'hf_opt_failed.qcout'), os.path.join(scr_dir, 'hf_opt_failed.qcout'))
    h = QChemErrorHandler(input_file='hf_opt_failed_tried_0.qcinp', output_file='hf_opt_failed.qcout')
    has_error = h.check()
    self.assertTrue(has_error)
    d = h.correct()
    self.assertEqual(d, {
        'errors': ['Geometry optimization failed'],
        'actions': ['GDIIS'],
    })
    with open(os.path.join(test_dir, 'hf_opt_failed_tried_1.qcinp')) as f:
        ref = [line.strip() for line in f.readlines()]
    with open(os.path.join(scr_dir, 'hf_opt_failed_tried_0.qcinp')) as f:
        ans = [line.strip() for line in f.readlines()]
    self.assertEqual(d, ans)
    shutil.copyfile(os.path.join(test_dir, 'hf_opt_failed_tried_1.qcinp'), os.path.join(scr_dir, 'hf_opt_failed_tried_1.qcinp'))
    shutil.copyfile(os.path.join(test_dir, 'hf_opt_failed.qcout'), os.path.join(scr_dir, 'hf_opt_failed.qcout'))
    h = QChemErrorHandler(input_file='hf_opt_failed_tried_1.qcinp', output_file='hf_opt_failed.qcout')
    has_error = h.check()
    self.assertTrue(has_error)
    d = h.correct()
    self.assertEqual(d, {
        'errors': ['Geometry optimization failed'],
        'actions': ['CartCoords'],
    })
    with open(os.path.join(test_dir, 'hf_opt_failed_tried_2.qcinp')) as f:
        ref = [line.strip() for line in f.readlines()]
    with open(os.path.join(scr_dir, 'hf_opt_failed_tried_1.qcinp')) as f:
        ans = [line.strip() for line in f.readlines()]
    self.assertEqual(ref, ans)
    shutil.copyfile(os.path.join(test_dir, 'hf_opt_failed_tried_2.qcinp'), os.path.join(scr_dir, 'hf_opt_failed_tried_2.qcinp'))
    shutil.copyfile(os.path.join(test_dir, 'hf_opt_failed.qcout'), os.path.join(scr_dir, 'hf_opt_failed.qcout'))
    h = QChemErrorHandler(input_file='hf_opt_failed_tried_2.qcinp', output_file='hf_opt_failed.qcout')
    has_error = h.check()
    self.assertTrue(has_error)
    d = h.correct()
    self.assertEqual(d, {
        'errors': ['Geometry optimization failed'],
        'actions': None,
    })

dataset/ETHPy150Open materialsproject/custodian/custodian/qchem/tests/test_handlers.py QChemErrorHandlerTest.test_opt_failed/VarMisuse@405/652 `ref`->`d`