Fix test cases that break in Docker, improve test for running in Docker

This commit is contained in:
James R. Barlow
2016-02-20 23:47:37 -08:00
parent 323b9a5f8e
commit 7c5e58a497
2 changed files with 9 additions and 1 deletions
-1
View File
@@ -80,7 +80,6 @@ USER docker
WORKDIR /home/docker
ENV OCRMYPDF_TEST_OUTPUT=/tmp/test-output
ENV OCRMYPDF_IN_DOCKER=1
ENV OCRMYPDF_SHARP_TTF=1
# Must use array form of ENTRYPOINT
+9
View File
@@ -28,6 +28,11 @@ TEST_OUTPUT = os.environ.get(
default=os.path.join(PROJECT_ROOT, 'tests', 'output', 'main'))
def running_in_docker():
# Docker creates a file named /.dockerinit
return os.path.exists('/.dockerinit')
def setup_module():
with suppress(FileNotFoundError):
shutil.rmtree(TEST_OUTPUT)
@@ -105,6 +110,8 @@ def spoof_tesseract_noop():
@pytest.fixture
def spoof_tesseract_cache():
if running_in_docker():
return os.environ.copy()
return spoof('tesseract', "tesseract_cache.py")
@@ -408,6 +415,8 @@ def test_missing_docinfo(spoof_tesseract_noop):
assert p.returncode == ExitCode.ok, err
@pytest.mark.skipif(running_in_docker(),
reason="writes to tests/resources")
def test_uppercase_extension(spoof_tesseract_noop):
shutil.copy(_infile("skew.pdf"), _infile("UPPERCASE.PDF"))
try: