mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-08 20:58:11 +00:00
test: avoid testing exact JSON in CSV backend (#1038)
* feat: updated verify_export Moved verify_export to verify_utils Reuse verify_export in tests Signed-off-by: Matheus Abdias <matheusfabdias@gmail.com> * feat: replace verify_export with verify_document in CSV conversion tests Signed-off-by: Matheus Abdias <matheusfabdias@gmail.com> --------- Signed-off-by: Matheus Abdias <matheusfabdias@gmail.com>
This commit is contained in:
@@ -472,3 +472,17 @@ def verify_document(pred_doc: DoclingDocument, gtfile: str, generate: bool = Fal
|
||||
true_doc = DoclingDocument.model_validate_json(fr.read())
|
||||
|
||||
return verify_docitems(pred_doc, true_doc, fuzzy=False)
|
||||
|
||||
|
||||
def verify_export(pred_text: str, gtfile: str, generate: bool = False) -> bool:
|
||||
file = Path(gtfile)
|
||||
|
||||
if not file.exists() or generate:
|
||||
with file.open("w") as fw:
|
||||
fw.write(pred_text)
|
||||
return True
|
||||
|
||||
with file.open("r") as fr:
|
||||
true_text = fr.read()
|
||||
|
||||
return pred_text == true_text
|
||||
|
||||
Reference in New Issue
Block a user