diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 42b8e78f..00000000 --- a/.coveragerc +++ /dev/null @@ -1,24 +0,0 @@ -[paths] -source = - src - */site-packages - -[run] -branch = true -parallel = true -concurrency = - thread - multiprocessing -source = - src/ocrmypdf - -[report] -exclude_lines = - pragma: no cover - def __repr__ - raise AssertionError - raise NotImplementedError - if 0: - if False: - if __name__ == .__main__.: - if TYPE_CHECKING: diff --git a/setup.cfg b/setup.cfg index 603daa71..44ed90c5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,6 +15,8 @@ filterwarnings = ignore:.*XMLParser.*:DeprecationWarning markers = slow +addopts = + -n auto [isort] multi_line_output=3 @@ -27,3 +29,30 @@ known_third_party = PIL,_cffi_backend,cffi,flask,img2pdf,pdfminer,pikepdf,pkg_re [metadata] license_file = LICENSE + +[coverage:paths] +source = + src/ + +[coverage:run] +branch = true +parallel = true +concurrency = multiprocessing +source = + src/ocrmypdf + +[coverage:report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + # Don't complain if non-runnable code isn't run: + if 0: + if False: + if __name__ == .__main__.: + if TYPE_CHECKING: diff --git a/src/ocrmypdf/_sync.py b/src/ocrmypdf/_sync.py index a4839aea..83de4150 100644 --- a/src/ocrmypdf/_sync.py +++ b/src/ocrmypdf/_sync.py @@ -338,6 +338,8 @@ def run_pipeline(options, *, plugin_manager, api=False): and not api ): # Debug log for command line interface only with verbose output + # See https://github.com/pytest-dev/pytest/issues/5502 for why we skip this + # when pytest is running debug_log_handler = configure_debug_logging(Path(work_folder) / "debug.log") pikepdf_enable_mmap() diff --git a/src/ocrmypdf/optimize.py b/src/ocrmypdf/optimize.py index 9fd80db7..c097e32e 100644 --- a/src/ocrmypdf/optimize.py +++ b/src/ocrmypdf/optimize.py @@ -498,7 +498,7 @@ def transcode_pngs( @deprecated -def rewrite_png_as_g4(pike: Pdf, im_obj: Object, compdata) -> None: +def rewrite_png_as_g4(pike: Pdf, im_obj: Object, compdata) -> None: # pragma: no cover im_obj.BitsPerComponent = 1 im_obj.Width = compdata.w im_obj.Height = compdata.h @@ -519,7 +519,7 @@ def rewrite_png_as_g4(pike: Pdf, im_obj: Object, compdata) -> None: @deprecated -def rewrite_png(pike: Pdf, im_obj: Object, compdata) -> None: +def rewrite_png(pike: Pdf, im_obj: Object, compdata) -> None: # pragma: no cover # When a PNG is inserted into a PDF, we more or less copy the IDAT section from # the PDF and transfer the rest of the PNG headers to PDF image metadata. # One thing we have to do is tell the PDF reader whether a predictor was used diff --git a/tests/conftest.py b/tests/conftest.py index 7619769f..70741548 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -137,16 +137,7 @@ def run_ocrmypdf(input_file, output_file, *args, text=True): + [str(input_file), str(output_file)] ) - # Tell subprocess where to find coverage.py configuration - # This has no unless except when coverage is running - # Details: https://coverage.readthedocs.io/en/coverage-5.0/subprocess.html - coverage_rc = Path(__file__).parent.parent / '.coveragerc' env = os.environ.copy() - if coverage_rc.exists(): - env['COVERAGE_PROCESS_START'] = os.fspath(coverage_rc) - elif not running_in_docker(): - assert False, "could not find .coveragerc" - p = run( p_args, stdout=PIPE,