def test_language_pipe_error_handler_make_doc_preferred(n_process): """Test the error handling for make_doc""" ops = get_current_ops() if isinstance(ops, NumpyOps) or n_process < 2: nlp = English() nlp.max_length = 10 texts = ["12345678901234567890", "12345"] * 10 with pytest.raises(ValueError): list(nlp.pipe(texts, n_process=n_process)) nlp.default_error_handler = ignore_error docs = list(nlp.pipe(texts, n_process=n_process)) assert len(docs) == 0
def test_language_pipe_error_handler_make_doc_actual(n_process): """Test the error handling for make_doc""" # TODO: fix so that the following test is the actual behavior ops = get_current_ops() if isinstance(ops, NumpyOps) or n_process < 2: nlp = English() nlp.max_length = 10 texts = ["12345678901234567890", "12345"] * 10 with pytest.raises(ValueError): list(nlp.pipe(texts, n_process=n_process)) nlp.default_error_handler = ignore_error if n_process == 1: with pytest.raises(ValueError): list(nlp.pipe(texts, n_process=n_process)) else: docs = list(nlp.pipe(texts, n_process=n_process)) assert len(docs) == 0