From c6b2fa8851df3c1b23c3c2f2c525700d76ddb0e3 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 2 Jun 2020 02:42:14 -0700 Subject: [PATCH] Remove unpaper spoof; no plugin needed --- tests/spoof/unpaper_oldversion.py | 37 ------------------------------- tests/test_unpaper.py | 20 ++++++++--------- 2 files changed, 10 insertions(+), 47 deletions(-) delete mode 100755 tests/spoof/unpaper_oldversion.py diff --git a/tests/spoof/unpaper_oldversion.py b/tests/spoof/unpaper_oldversion.py deleted file mode 100755 index ff2e27ea..00000000 --- a/tests/spoof/unpaper_oldversion.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 -# © 2016 James R. Barlow: github.com/jbarlow83 -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -import sys - - -def main(): - if sys.argv[1] == '--version': - print('0.5') - sys.exit(0) - - print("Only supports --version") - sys.exit(1) - - -if __name__ == '__main__': - main() diff --git a/tests/test_unpaper.py b/tests/test_unpaper.py index 5ef9fac3..3b9f155e 100644 --- a/tests/test_unpaper.py +++ b/tests/test_unpaper.py @@ -35,11 +35,6 @@ spoof = pytest.helpers.spoof have_unpaper = pytest.helpers.have_unpaper -@pytest.fixture -def spoof_unpaper_oldversion(tmp_path_factory): - return spoof(tmp_path_factory, unpaper="unpaper_oldversion.py") - - def test_no_unpaper(resources, no_outpdf): input_ = fspath(resources / "c02-22.pdf") output = fspath(no_outpdf) @@ -52,11 +47,16 @@ def test_no_unpaper(resources, no_outpdf): check_options(options, pm) -def test_old_unpaper(spoof_unpaper_oldversion, resources, no_outpdf): - p, out, err = run_ocrmypdf( - resources / "c02-22.pdf", no_outpdf, "--clean", env=spoof_unpaper_oldversion - ) - assert p.returncode == ExitCode.missing_dependency +def test_old_unpaper(resources, no_outpdf): + input_ = fspath(resources / "c02-22.pdf") + output = fspath(no_outpdf) + + _parser, options, pm = get_parser_options_plugins(["--clean", input_, output]) + with patch("ocrmypdf.exec.unpaper.version") as mock_unpaper_version: + mock_unpaper_version.return_value = '0.5' + + with pytest.raises(MissingDependencyError): + check_options(options, pm) @pytest.mark.skipif(not have_unpaper(), reason="requires unpaper")