Update OCR app tests to work with Python 3.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-09-06 16:59:38 -04:00
parent e41f2f73e7
commit 4ae7a32443
2 changed files with 5 additions and 35 deletions

View File

@@ -6,32 +6,15 @@ from common.tests import BaseTestCase
from documents.models import DocumentType
from documents.runtime import language_choices
from documents.tests import (
TEST_DEU_DOCUMENT_PATH, TEST_DOCUMENT_TYPE_LABEL, TEST_SMALL_DOCUMENT_PATH
DocumentTestMixin, TEST_DEU_DOCUMENT_PATH, TEST_DOCUMENT_TYPE_LABEL
)
class DocumentOCRTestCase(BaseTestCase):
class DocumentOCRTestCase(DocumentTestMixin, BaseTestCase):
# PyOCR's leak descriptor in get_available_languages and image_to_string
# Disable descriptor leak test until fixed in upstream
_skip_file_descriptor_test = True
def setUp(self):
super(DocumentOCRTestCase, self).setUp()
self.document_type = DocumentType.objects.create(
label=TEST_DOCUMENT_TYPE_LABEL
)
with open(TEST_SMALL_DOCUMENT_PATH) as file_object:
self.document = self.document_type.new_document(
file_object=file_object,
)
def tearDown(self):
self.document.delete()
self.document_type.delete()
super(DocumentOCRTestCase, self).tearDown()
def test_ocr_language_backends_end(self):
content = self.document.pages.first().ocr_content.content
self.assertTrue('Mayan EDMS Documentation' in content)
@@ -57,7 +40,7 @@ class GermanOCRSupportTestCase(BaseTestCase):
self.assertEqual('deu', language_code)
with open(TEST_DEU_DOCUMENT_PATH) as file_object:
with open(TEST_DEU_DOCUMENT_PATH, 'rb') as file_object:
self.document = self.document_type.new_document(
file_object=file_object, language=language_code
)