Fix any False in the ocrmypdf.ocr() API being set to True

This commit is contained in:
James R. Barlow
2019-09-15 01:47:31 -07:00
parent 6e8b0c3194
commit a8565bac6e
2 changed files with 32 additions and 3 deletions
+20 -1
View File
@@ -16,13 +16,14 @@
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import os
from unittest.mock import MagicMock, patch
from unittest.mock import MagicMock, patch, call
import pytest
import ocrmypdf._validation as vd
from ocrmypdf.api import create_options
from ocrmypdf.exceptions import MissingDependencyError, BadArgsError
from ocrmypdf.pdfinfo import PdfInfo
def make_opts(input_file='a.pdf', output_file='b.pdf', language='eng', **kwargs):
@@ -119,3 +120,21 @@ def test_report_file_size(tmp_path, caplog):
os.truncate(out, 50000)
vd.report_output_file_size(opts, in_, out)
assert 'No reason' in caplog.text
def test_false_action_store_true():
opts = make_opts(keep_temporary_files=True)
assert opts.keep_temporary_files == True
opts = make_opts(keep_temporary_files=False)
assert opts.keep_temporary_files == False
@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:
vd.check_options(opts)
pdfinfo = PdfInfo(opts.input_file, progbar=opts.progress_bar)
assert tqdmpatch.called
_args, kwargs = tqdmpatch.call_args
assert kwargs['disable'] != progress_bar