Improve some documentation for tests
This commit is contained in:
@@ -8,13 +8,7 @@ VERSION_STRING = '''tesseract 3.04.00
|
||||
SPOOFED: return error claiming image too big
|
||||
'''
|
||||
|
||||
"""Simulates a Tesseract crash
|
||||
|
||||
It isn't strictly necessary to crash the process and that has unwanted
|
||||
side effects like triggering core dumps or error reporting, logging and such.
|
||||
It's enough to dump some text to stderr and return an error code.
|
||||
|
||||
Follows the POSIX? convention of returning 128 + signal number.
|
||||
"""Simulates an error of Tesseract failing on attempts to process large images
|
||||
|
||||
"""
|
||||
|
||||
|
||||
@@ -6,6 +6,25 @@ import shutil
|
||||
import subprocess
|
||||
|
||||
|
||||
"""Cache output of tesseract to speed up test suite
|
||||
|
||||
The cache is keyed by a hash that includes the tesseract version, some of
|
||||
the command line, and the binary dump of the input file. The output file,
|
||||
stdout, and stderr are replicated on a cache hit.
|
||||
|
||||
Page orientation checks are also cached (-psm 0 stdout)
|
||||
|
||||
Errors and crashes are not cached.
|
||||
|
||||
Things not checked:
|
||||
-changes to tesseract installation that don't affect --version
|
||||
|
||||
Will fail on Tesseract 3.02.02 in "hocr" mode because it doesn't produce
|
||||
the incorrect file extension.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
CACHE_PATH = os.path.abspath(os.path.join(
|
||||
os.path.dirname(__file__), '..', 'cache'))
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ VERSION_STRING = '''tesseract 3.04.00
|
||||
SPOOFED: CRASH ON OCR or -psm 0
|
||||
'''
|
||||
|
||||
"""Simulates a Tesseract crash
|
||||
"""Simulates a Tesseract crash when asked to run OCR
|
||||
|
||||
It isn't strictly necessary to crash the process and that has unwanted
|
||||
side effects like triggering core dumps or error reporting, logging and such.
|
||||
It's enough to dump some text to stderr and return an error code.
|
||||
|
||||
Follows the POSIX? convention of returning 128 + signal number.
|
||||
Follows the POSIX(?) convention of returning 128 + signal number.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
@@ -4,6 +4,18 @@ import img2pdf
|
||||
from PIL import Image
|
||||
|
||||
|
||||
"""Tesseract no-op spoof
|
||||
|
||||
To quickly run tests where getting OCR output is not necessary.
|
||||
|
||||
In 'hocr' mode, create a .hocr file that specifies no text found.
|
||||
|
||||
In 'pdf' mode, convert the image to PDF using another program.
|
||||
|
||||
In orientation check mode, report the orientation is upright.
|
||||
"""
|
||||
|
||||
|
||||
VERSION_STRING = '''tesseract 3.04.00
|
||||
leptonica-1.72
|
||||
libjpeg 8d : libpng 1.6.19 : libtiff 4.0.6 : zlib 1.2.5
|
||||
|
||||
@@ -614,6 +614,8 @@ def test_stdin(spoof_tesseract_noop):
|
||||
input_file = _infile('francais.pdf')
|
||||
output_file = _outfile('test_stdin.pdf')
|
||||
|
||||
# Runs: cat testfile.pdf | ocrmypdf - output.pdf
|
||||
|
||||
p1_args = ['cat', input_file]
|
||||
p1 = Popen(p1_args, close_fds=True, stdin=DEVNULL, stdout=PIPE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user