Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

use imported List fail test if non-existing dir exists

Florian Brandes08fbcf515844
diff --git a/src/documents/tasks.py b/src/documents/tasks.py
index 7bd212399..42d50549d 100644
--- a/src/documents/tasks.py
+++ b/src/documents/tasks.py
@@ -2,6 +2,7 @@ import logging
import os
import shutil
import tempfile
+from typing import List # for type hinting. Can be removed, if only Python >3.8 is used
import tqdm
from asgiref.sync import async_to_sync
@@ -24,6 +25,7 @@ from pikepdf import Pdf
from pyzbar import pyzbar
from whoosh.writing import AsyncWriter
+
logger = logging.getLogger("paperless.tasks")
@@ -70,7 +72,7 @@ def train_classifier():
logger.warning("Classifier error: " + str(e))
-def barcode_reader(image) -> list[str]:
+def barcode_reader(image) -> List[str]:
"""
Read any barcodes contained in image
Returns a list containing all found barcodes
@@ -91,7 +93,7 @@ def barcode_reader(image) -> list[str]:
return barcodes
-def scan_file_for_separating_barcodes(filepath: str) -> list[int]:
+def scan_file_for_separating_barcodes(filepath: str) -> List[int]:
"""
Scan the provided file for page separating barcodes
Returns a list of pagenumbers, which separate the file
@@ -108,7 +110,7 @@ def scan_file_for_separating_barcodes(filepath: str) -> list[int]:
return separator_page_numbers
-def separate_pages(filepath: str, pages_to_split_on: list[int]) -> list[str]:
+def separate_pages(filepath: str, pages_to_split_on: List[int]) -> List[str]:
"""
Separate the provided file on the pages_to_split_on.
The pages which are defined by page_numbers will be removed.
diff --git a/src/documents/tests/test_tasks.py b/src/documents/tests/test_tasks.py
index 1b59b7109..46be59d53 100644
--- a/src/documents/tests/test_tasks.py
+++ b/src/documents/tests/test_tasks.py
@@ -313,7 +313,7 @@ class TestTasks(DirectoriesMixin, TestCase):
)
nonexistingdir = "/nowhere"
if os.path.isdir(nonexistingdir):
- self.skipTest("non-existing dir exists")
+ self.fail("non-existing dir exists")
else:
with self.assertLogs("paperless.tasks", level="WARNING") as cm:
tasks.save_to_dir(test_file, target_dir=nonexistingdir)