From 3f92867ae678da3270722bc24e4ec9b3b26383c4 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 19 Nov 2019 18:01:10 -0800 Subject: [PATCH] Fix TypeError "environment can only contain strings" Apparently Windows Python doesn't coerce pathlib.Path to str. --- src/ocrmypdf/api.py | 2 +- tests/conftest.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ocrmypdf/api.py b/src/ocrmypdf/api.py index b735f398..a05edbc1 100644 --- a/src/ocrmypdf/api.py +++ b/src/ocrmypdf/api.py @@ -158,7 +158,7 @@ def create_options(*, input_file, output_file, **kwargs): # If we are running a Tesseract spoof, ensure it knows what the input file is if os.environ.get('PYTEST_CURRENT_TEST') and options.tesseract_env: - options.tesseract_env['_OCRMYPDF_TEST_INFILE'] = input_file + options.tesseract_env['_OCRMYPDF_TEST_INFILE'] = os.fspath(input_file) return options diff --git a/tests/conftest.py b/tests/conftest.py index b443ac1f..e875315a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -183,7 +183,7 @@ def check_ocrmypdf(input_file, output_file, *args, env=None): api.check_options(options) if env: options.tesseract_env = env - options.tesseract_env['_OCRMYPDF_TEST_INFILE'] = input_file + options.tesseract_env['_OCRMYPDF_TEST_INFILE'] = os.fspath(input_file) result = api.run_pipeline(options, api=True) assert result == 0