From 7f0b8621f3aa651fe4007ab8eb668616eafcac4f Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 21 Jul 2017 16:39:22 -0700 Subject: [PATCH] Tests: accept rich path objects without having to str() everything --- tests/conftest.py | 3 ++- tests/test_main.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 319fcbd0..1a74b57c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -129,7 +129,8 @@ def run_ocrmypdf(input_file, output_file, *args, env=None): if env is None: env = os.environ - p_args = OCRMYPDF + list(args) + [str(input_file), str(output_file)] + p_args = OCRMYPDF + [str(arg) for arg in args] + \ + [str(input_file), str(output_file)] p = Popen( p_args, close_fds=True, stdout=PIPE, stderr=PIPE, universal_newlines=True, env=env) diff --git a/tests/test_main.py b/tests/test_main.py index e30aa86d..8193a1a8 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -755,7 +755,7 @@ language_model_penalty_non_freq_dict_word 0 check_ocrmypdf( resources / 'ccitt.pdf', outdir / 'out.pdf', - '--tesseract-config', str(cfg_file)) + '--tesseract-config', cfg_file) @pytest.mark.parametrize('renderer', RENDERERS) @@ -765,7 +765,7 @@ def test_tesseract_config_notfound(renderer, resources, outdir): p, out, err = run_ocrmypdf( resources / 'ccitt.pdf', outdir / 'out.pdf', '--pdf-renderer', renderer, - '--tesseract-config', str(cfg_file)) + '--tesseract-config', cfg_file) assert "Can't open" in err, "No error message about missing config file" assert p.returncode == ExitCode.ok @@ -781,7 +781,7 @@ THIS FILE IS INVALID p, out, err = run_ocrmypdf( resources / 'ccitt.pdf', outdir / 'out.pdf', '--pdf-renderer', renderer, - '--tesseract-config', str(cfg_file)) + '--tesseract-config', cfg_file) assert "parameter not found" in err, "No error message" assert p.returncode == ExitCode.invalid_config