Allow piping output to stdout

This commit is contained in:
James R. Barlow
2016-10-27 16:14:42 -07:00
parent f7387b0859
commit 2e4431cc63
2 changed files with 39 additions and 13 deletions
+18
View File
@@ -662,6 +662,24 @@ def test_stdin(spoof_tesseract_noop):
assert p.returncode == ExitCode.ok
def test_stdout(spoof_tesseract_noop):
input_file = _infile('francais.pdf')
output_file = _outfile('test_stdout.pdf')
# Runs: ocrmypdf francais.pdf - > test_stdout.pdf
with open(output_file, 'wb') as output_stream:
p_args = OCRMYPDF + [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 import qpdf
assert qpdf.check(output_file, log=None)
def test_masks(spoof_tesseract_noop):
check_ocrmypdf('masks.pdf', 'test_masks.pdf', env=spoof_tesseract_noop)