add the following dependancies to a requirements.txt file ( in the root ) and pip install them with pip install -r requirements.txt
textract==1.6.5
pytest==6.2.4
Create a test in a file also placed in the root of your project @ test_textract.py
import textract
class TestTextract:
def test_occorunces_of_string(self):
path = "sample_sectionals.pdf"
extracted_text = textract.process(path, method="pdfminer").decode("utf-8")
while "\n" in extracted_text or "\n" in extracted_text:
extracted_text = extracted_text.replace("\n", " ")
extracted_text = extracted_text.replace("\n", " ")
5. Run test with command: `pytest -s -vv`
6. Add a Dockerfile in the root with the following content:
```docker
FROM python:3.8.13-slim-buster
RUN pip install --upgrade pip
COPY . /opt/code
RUN pip install textract==1.6.5 pytest==6.2.4
WORKDIR /opt/code
ENTRYPOINT [ "/bin/sh" ]
docker build . -t test
docker run test -c "pytest -s -vv test_textract.py"
Expected behaviour
This test passes locally, and fails in Docker container ( with zero occurrences )
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Describe the bug I operate locally on a Mac and a simple test from a sample pdf passes locally, but fails in a Docker container.
To Reproduce Steps to reproduce the behaviour:
requirements.txt
file ( in the root ) and pip install them withpip install -r requirements.txt
test_textract.py
class TestTextract: def test_occorunces_of_string(self): path = "sample_sectionals.pdf" extracted_text = textract.process(path, method="pdfminer").decode("utf-8") while "\n" in extracted_text or "\n" in extracted_text: extracted_text = extracted_text.replace("\n", " ") extracted_text = extracted_text.replace("\n", " ")
docker build . -t test
docker run test -c "pytest -s -vv test_textract.py"
Expected behaviour This test passes locally, and fails in Docker container ( with zero occurrences )
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):