def test_dump_error_file_overwrite_existing(self): dst_error_file = os.path.join(self.test_dir, "dst_error.json") src_error_file = os.path.join(self.test_dir, "src_error.json") _write_error(RuntimeError("foo"), dst_error_file) _write_error(RuntimeError("bar"), src_error_file) with patch.dict(os.environ, {"TORCHELASTIC_ERROR_FILE": dst_error_file}): eh = ErrorHandler() eh.dump_error_file(src_error_file) self.assertTrue(filecmp.cmp(src_error_file, dst_error_file))
def test_dump_error_file(self): src_error_file = os.path.join(self.test_dir, "src_error.json") eh = ErrorHandler() with patch.dict(os.environ, {"TORCHELASTIC_ERROR_FILE": src_error_file}): eh.record_exception(RuntimeError("foobar")) with patch.dict(os.environ, {"TORCHELASTIC_ERROR_FILE": self.test_error_file}): eh.dump_error_file(src_error_file) self.assertTrue(filecmp.cmp(src_error_file, self.test_error_file)) with patch.dict(os.environ, {}): eh.dump_error_file(src_error_file)