From de9126b312d13aa858b00c71939ef692b9dc040c Mon Sep 17 00:00:00 2001 From: Lasse Date: Thu, 15 Dec 2022 14:51:41 +0100 Subject: [PATCH] test: multiprocessing in quality component --- textdescriptives/tests/test_quality.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/textdescriptives/tests/test_quality.py b/textdescriptives/tests/test_quality.py index 2190b5b3..802fcfc9 100644 --- a/textdescriptives/tests/test_quality.py +++ b/textdescriptives/tests/test_quality.py @@ -4,6 +4,7 @@ from typing import List, Tuple +import ftfy import pytest import spacy @@ -18,6 +19,8 @@ top_ngram_chr_fraction, ) +from .books import flatland, oliver_twist, secret_garden + @pytest.fixture def nlp(): @@ -254,3 +257,12 @@ def test_passed_quality_check(text: str, passed: bool, nlp: spacy.Language): nlp.add_pipe("textdescriptives.quality", config={"force": True}) doc = nlp(text) assert doc._.passed_quality_check == passed + + +def test_quality_multi_process(nlp): + texts = [oliver_twist, secret_garden, flatland] + texts = [ftfy.fix_text(text) for text in texts] + + docs = nlp.pipe(texts, n_process=3) + for doc in docs: + assert doc._.quality