From 7513f5425c7fbd7c8ef9bcdca7016d5d1cdcd055 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sat, 11 Apr 2020 01:21:07 -0700 Subject: [PATCH] Fix some broken tests --- src/ocrmypdf/_concurrent.py | 18 +++++++++--------- src/ocrmypdf/pdfinfo/info.py | 2 +- tests/test_validation.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ocrmypdf/_concurrent.py b/src/ocrmypdf/_concurrent.py index 724e6484..7253ab89 100644 --- a/src/ocrmypdf/_concurrent.py +++ b/src/ocrmypdf/_concurrent.py @@ -24,7 +24,7 @@ import sys import threading from multiprocessing import Pool as ProcessPool from multiprocessing.dummy import Pool as ThreadPool -from pathlib import Path +from typing import Callable, Iterable, Optional from tqdm import tqdm @@ -76,14 +76,14 @@ def thread_init(_queue, userfn, *userargs): def exec_progress_pool( *, - use_threads, - max_workers, - tqdm_kwargs, - task_initializer=None, - task_initargs=None, - task=None, - task_arguments=None, - task_finished=None, + use_threads: bool, + max_workers: int, + tqdm_kwargs: dict, + task_initializer: Optional[Callable] = None, + task_initargs: Optional[tuple] = None, + task: Optional[Callable] = None, + task_arguments: Optional[Iterable] = None, + task_finished: Optional[Callable] = None, ): log_queue = multiprocessing.Queue(-1) listener = threading.Thread(target=log_listener, args=(log_queue,)) diff --git a/src/ocrmypdf/pdfinfo/info.py b/src/ocrmypdf/pdfinfo/info.py index 97ddb1d8..c5e0f9db 100644 --- a/src/ocrmypdf/pdfinfo/info.py +++ b/src/ocrmypdf/pdfinfo/info.py @@ -651,7 +651,7 @@ def _pdf_pageinfo_concurrent(pdf, infile, pages_xml, detailed_analysis, progbar) exec_progress_pool( use_threads=use_threads, - max_workers=1, + max_workers=max_workers, tqdm_kwargs=dict( total=len(pdf.pages), desc="Scan", unit='page', disable=not progbar ), diff --git a/tests/test_validation.py b/tests/test_validation.py index af1eadea..864dd05a 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -150,7 +150,7 @@ def test_false_action_store_true(): @pytest.mark.parametrize('progress_bar', [True, False]) def test_no_progress_bar(progress_bar, resources): opts = make_opts(progress_bar=progress_bar, input_file=(resources / 'trivial.pdf')) - with patch('ocrmypdf.pdfinfo.info.tqdm', autospec=True) as tqdmpatch: + with patch('ocrmypdf._concurrent.tqdm', autospec=True) as tqdmpatch: vd.check_options(opts) pdfinfo = PdfInfo(opts.input_file, progbar=opts.progress_bar) assert pdfinfo is not None