|
17 | 17 | import certifi |
18 | 18 | from PIL import Image |
19 | 19 |
|
20 | | -# Check if the PYTEST_DONUT flag is set to enable OCR testing |
21 | | -DONUT_TESTING_ENABLED = os.environ.get("PYTEST_DONUT", "").lower() == "yes" |
22 | | - |
23 | 20 | from datafog.processing.image_processing.donut_processor import DonutProcessor |
24 | 21 | from datafog.processing.image_processing.pytesseract_processor import ( |
25 | 22 | PytesseractProcessor, |
26 | 23 | ) |
27 | 24 |
|
| 25 | +# Check if the PYTEST_DONUT flag is set to enable OCR testing |
| 26 | +DONUT_TESTING_ENABLED = os.environ.get("PYTEST_DONUT", "").lower() == "yes" |
| 27 | + |
28 | 28 |
|
29 | 29 | class ImageDownloader: |
30 | 30 | """Asynchronous image downloader with SSL support.""" |
@@ -56,18 +56,26 @@ def __init__(self, use_donut: bool = False, use_tesseract: bool = True): |
56 | 56 | self.downloader = ImageDownloader() |
57 | 57 |
|
58 | 58 | # Check if we're in a test environment |
59 | | - in_test_env = "PYTEST_CURRENT_TEST" in os.environ or "TOX_ENV_NAME" in os.environ |
| 59 | + in_test_env = ( |
| 60 | + "PYTEST_CURRENT_TEST" in os.environ or "TOX_ENV_NAME" in os.environ |
| 61 | + ) |
60 | 62 |
|
61 | 63 | # Log the initial OCR processor selection |
62 | | - logging.info(f"Initial OCR processor selection: use_donut={use_donut}, use_tesseract={use_tesseract}") |
63 | | - |
| 64 | + logging.info( |
| 65 | + f"Initial OCR processor selection: use_donut={use_donut}, use_tesseract={use_tesseract}" |
| 66 | + ) |
| 67 | + |
64 | 68 | # In test environment without PYTEST_DONUT=yes, we should still allow Donut for testing |
65 | 69 | # but the DonutProcessor will return mock results |
66 | 70 | if in_test_env: |
67 | 71 | if DONUT_TESTING_ENABLED: |
68 | | - logging.info("PYTEST_DONUT=yes is set, enabling real Donut OCR in test environment") |
| 72 | + logging.info( |
| 73 | + "PYTEST_DONUT=yes is set, enabling real Donut OCR in test environment" |
| 74 | + ) |
69 | 75 | else: |
70 | | - logging.info("Test environment detected without PYTEST_DONUT=yes, Donut will use mock results") |
| 76 | + logging.info( |
| 77 | + "Test environment detected without PYTEST_DONUT=yes, Donut will use mock results" |
| 78 | + ) |
71 | 79 |
|
72 | 80 | if use_donut and use_tesseract: |
73 | 81 | raise ValueError( |
|
0 commit comments