A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
test case fixes.
jonaswinkler06cfc3113aaf
diff --git a/src/paperless_tesseract/tests/test_ocr.py b/src/paperless_tesseract/tests/test_ocr.pydeleted file mode 100644index 7124fbed6..000000000--- a/src/paperless_tesseract/tests/test_ocr.py+++ /dev/null@@ -1,34 +0,0 @@-import os-from unittest import mock, skipIf--from django.test import TestCase--from ..parsers import strip_excess_whitespace---class TestOCR(TestCase):-- text_cases = [- ("simple string", "simple string"),- (- "simple newline\n testing string",- "simple newline\ntesting string"- ),- (- "utf-8 строка с пробелами в конце ",- "utf-8 строка с пробелами в конце"- )- ]-- def test_strip_excess_whitespace(self):- for source, result in self.text_cases:- actual_result = strip_excess_whitespace(source)- self.assertEqual(- result,- actual_result,- "strip_exceess_whitespace({}) != '{}', but '{}'".format(- source,- result,- actual_result- )- )diff --git a/src/paperless_tesseract/tests/test_parser.py b/src/paperless_tesseract/tests/test_parser.pyindex 70fb494ef..18af3ed59 100644--- a/src/paperless_tesseract/tests/test_parser.py+++ b/src/paperless_tesseract/tests/test_parser.py@@ -1,6 +1,4 @@import os-import shutil-import tempfileimport uuidfrom typing import ContextManagerfrom unittest import mock@@ -8,7 +6,8 @@ from unittest import mockfrom django.test import TestCase, override_settingsfrom documents.parsers import ParseError, run_convert-from paperless_tesseract.parsers import RasterisedDocumentParser, get_text_from_pdf+from documents.tests.utils import DirectoriesMixin+from paperless_tesseract.parsers import RasterisedDocumentParser, get_text_from_pdf, strip_excess_whitespaceimage_to_string_calls = []@@ -33,15 +32,32 @@ class FakeImageFile(ContextManager):return os.path.basename(self.fname)-class TestParser(TestCase):-- def setUp(self):- self.scratch = tempfile.mkdtemp()-- override_settings(SCRATCH_DIR=self.scratch).enable()-- def tearDown(self):- shutil.rmtree(self.scratch)+class TestParser(DirectoriesMixin, TestCase):++ text_cases = [+ ("simple string", "simple string"),+ (+ "simple newline\n testing string",+ "simple newline\ntesting string"+ ),+ (+ "utf-8 строка с пробелами в конце ",+ "utf-8 строка с пробелами в конце"+ )+ ]++ def test_strip_excess_whitespace(self):+ for source, result in self.text_cases:+ actual_result = strip_excess_whitespace(source)+ self.assertEqual(+ result,+ actual_result,+ "strip_exceess_whitespace({}) != '{}', but '{}'".format(+ source,+ result,+ actual_result+ )+ )SAMPLE_FILES = os.path.join(os.path.dirname(__file__), "samples")