Fix remaining 3.4/3.5 regressions
This commit is contained in:
@@ -20,7 +20,7 @@ import sys
|
||||
@pytest.fixture
|
||||
def blank_hocr(tmpdir):
|
||||
filename = Path(str(tmpdir)) / "blank.hocr"
|
||||
with open(filename, 'w') as f:
|
||||
with open(str(filename), 'w') as f:
|
||||
f.write(HOCR_TEMPLATE)
|
||||
return filename
|
||||
|
||||
@@ -31,8 +31,9 @@ def test_mono_image(blank_hocr, outdir):
|
||||
im.putpixel((n, n), 1)
|
||||
im.save(outdir / 'mono.tif', format='TIFF')
|
||||
|
||||
hocr = hocrtransform.HocrTransform(blank_hocr, 300)
|
||||
hocr.to_pdf(str(outdir / 'mono.pdf'), imageFileName=outdir / 'mono.tif')
|
||||
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'))
|
||||
|
||||
|
||||
+5
-4
@@ -242,10 +242,11 @@ def test_skip_ocr(spoof_tesseract_cache, resources, outpdf):
|
||||
|
||||
|
||||
def test_argsfile(spoof_tesseract_noop, resources, outdir):
|
||||
with open(outdir / 'test_argsfile.txt', 'w') as argsfile:
|
||||
path_argsfile = outdir / 'test_argsfile.txt'
|
||||
with open(str(path_argsfile), 'w') as argsfile:
|
||||
print('--title', 'ArgsFile Test', '--author', 'Test Cases',
|
||||
sep='\n', end='\n', file=argsfile)
|
||||
check_ocrmypdf(resources / 'graph.pdf', outdir / 'args.pdf',
|
||||
check_ocrmypdf(resources / 'graph.pdf', path_argsfile,
|
||||
'@' + str(outdir / 'test_argsfile.txt'),
|
||||
env=spoof_tesseract_noop)
|
||||
|
||||
@@ -473,9 +474,9 @@ def test_input_file_not_a_pdf(no_outpdf):
|
||||
|
||||
def test_qpdf_repair_fails(spoof_qpdf_always_error, resources, no_outpdf):
|
||||
p, out, err = run_ocrmypdf(
|
||||
resources / 'c02-22.pdf', no_outpdf,
|
||||
'-v', '1',
|
||||
resources / 'c02-22.pdf', no_outpdf, env=spoof_qpdf_always_error)
|
||||
print(out)
|
||||
env=spoof_qpdf_always_error)
|
||||
print(err)
|
||||
assert p.returncode == ExitCode.input_file
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ def test_single_page_text(outdir):
|
||||
assert len(page['images']) == 0
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 5), reason="needs Path.read_bytes")
|
||||
def test_single_page_image(outdir):
|
||||
filename = outdir / 'image-mono.pdf'
|
||||
|
||||
@@ -51,8 +52,7 @@ def test_single_page_image(outdir):
|
||||
pdf_bytes = img2pdf.convert(
|
||||
im_bytes, producer="img2pdf", with_pdfrw=False,
|
||||
layout_fun=layout_fun)
|
||||
with open(filename, 'wb') as pdf:
|
||||
pdf.write(pdf_bytes)
|
||||
filename.write_bytes(pdf_bytes)
|
||||
|
||||
pdfinfo = pageinfo.pdf_get_all_pageinfo(str(filename))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user