Fix some broken tests

This commit is contained in:
James R. Barlow
2020-04-11 01:21:07 -07:00
parent af3c3c6466
commit 7513f5425c
3 changed files with 11 additions and 11 deletions

View File

@@ -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,))

View File

@@ -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
),

View File

@@ -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