def test_mono_image(blank_hocr, outdir): im = Image.new('1', (8, 8), 0) for n in range(8): im.putpixel((n, n), 1) im.save(outdir / 'mono.tif', format='TIFF') hocr = hocrtransform.HocrTransform(str(blank_hocr), 300) hocr.to_pdf(str(outdir / 'mono.pdf'), imageFileName=str(outdir / 'mono.tif')) qpdf.check(str(outdir / 'mono.pdf'))
def test_mono_image(blank_hocr, outdir): im = Image.new('1', (8, 8), 0) for n in range(8): im.putpixel((n, n), 1) im.save(outdir / 'mono.tif', format='TIFF') hocr = hocrtransform.HocrTransform(str(blank_hocr), 300) hocr.to_pdf( str(outdir / 'mono.pdf'), imageFileName=str(outdir / 'mono.tif')) qpdf.check(str(outdir / 'mono.pdf'))
def test_stdout(spoof_tesseract_noop, ocrmypdf_exec, resources, outpdf): input_file = str(resources / 'francais.pdf') output_file = str(outpdf) # Runs: ocrmypdf francais.pdf - > test_stdout.pdf with open(output_file, 'wb') as output_stream: p_args = ocrmypdf_exec + [input_file, '-'] p = Popen( p_args, close_fds=True, stdout=output_stream, stderr=PIPE, stdin=DEVNULL, env=spoof_tesseract_noop) out, err = p.communicate() assert p.returncode == ExitCode.ok assert qpdf.check(output_file, log=None)
def test_stdout(spoof_tesseract_noop, ocrmypdf_exec, resources, outpdf): input_file = str(resources / 'francais.pdf') output_file = str(outpdf) # Runs: ocrmypdf francais.pdf - > test_stdout.pdf with open(output_file, 'wb') as output_stream: p_args = ocrmypdf_exec + [input_file, '-'] p = Popen( p_args, close_fds=True, stdout=output_stream, stderr=PIPE, stdin=DEVNULL, env=spoof_tesseract_noop) out, err = p.communicate() assert p.returncode == ExitCode.ok from ocrmypdf.exec import qpdf assert qpdf.check(output_file, log=None)
def test_stdout(spoof_tesseract_noop, ocrmypdf_exec, resources, outpdf): if 'COV_CORE_DATAFILE' in spoof_tesseract_noop: pytest.skip(msg="Coverage uses stdout") input_file = str(resources / 'francais.pdf') output_file = str(outpdf) # Runs: ocrmypdf francais.pdf - > test_stdout.pdf with open(output_file, 'wb') as output_stream: p_args = ocrmypdf_exec + [input_file, '-'] p = run( p_args, stdout=output_stream, stderr=PIPE, stdin=DEVNULL, env=spoof_tesseract_noop, ) assert p.returncode == ExitCode.ok assert qpdf.check(output_file, log=None)
def test_qpdf_error(resources): assert qpdf.check(resources / 'blank.pdf') assert not qpdf.check(__file__)
def test_qpdf_error(resources): assert qpdf.check(resources / 'blank.pdf') assert not qpdf.check(__file__)