Skip to content
Snippets Groups Projects
Commit 4294beed authored by Konrad Wojtasik's avatar Konrad Wojtasik
Browse files

Fix tests

parent 05afe1e1
Branches
1 merge request!4Resolve "Read not only .txt files"
Pipeline #11451 passed with stages
in 7 minutes and 2 seconds
......@@ -108,4 +108,5 @@ class EasymatcherWorker(nlp_ws.NLPWorker):
for out_document, document in zip(out_documents, documents):
# We want to keep content of the original labeled documents
document['label'] = out_document['label']
document['text'] = out_document['text']
_f.write(json.dumps(document) + "\n")
import os
import json
from filecmp import cmp
from pathlib import Path
def load_jsonl(file_path: Path):
with open(file_path) as f:
data = [json.loads(line) for line in f]
return data
def check_and_cleanup(output_path: Path, expected_path: Path) -> Path:
assert cmp(output_path, expected_path)
output = load_jsonl(output_path)
expected = load_jsonl(expected_path)
assert sorted(output, key=lambda d : d['text']) == sorted(expected, key=lambda d : d['text'])
os.remove(output_path)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment