diff --git a/mayan/apps/common/tests/test_compressed_files.py b/mayan/apps/common/tests/test_compressed_files.py index 597bd06c42..a89d0d3f61 100644 --- a/mayan/apps/common/tests/test_compressed_files.py +++ b/mayan/apps/common/tests/test_compressed_files.py @@ -23,22 +23,22 @@ class TarArchiveClassTestCase(BaseTestCase): def test_add_file(self): archive = self.cls() archive.create() - with open(self.file_path, 'rb') as file_object: + with open(self.file_path, mode='rb') as file_object: archive.add_file(file_object=file_object, filename=self.filename) self.assertTrue(archive.members(), [self.filename]) def test_open(self): - with open(self.archive_path, 'rb') as file_object: + with open(self.archive_path, mode='rb') as file_object: archive = Archive.open(file_object=file_object) self.assertTrue(isinstance(archive, self.cls)) def test_members(self): - with open(self.archive_path, 'rb') as file_object: + with open(self.archive_path, mode='rb') as file_object: archive = Archive.open(file_object=file_object) self.assertEqual(archive.members(), self.members_list) def test_member_contents(self): - with open(self.archive_path, 'rb') as file_object: + with open(self.archive_path, mode='rb') as file_object: archive = Archive.open(file_object=file_object) self.assertEqual( archive.member_contents(filename=self.member_name), @@ -46,7 +46,7 @@ class TarArchiveClassTestCase(BaseTestCase): ) def test_open_member(self): - with open(self.archive_path, 'rb') as file_object: + with open(self.archive_path, mode='rb') as file_object: archive = Archive.open(file_object=file_object) file_object = archive.open_member(filename=self.member_name) self.assertEqual( diff --git a/mayan/apps/common/utils.py b/mayan/apps/common/utils.py index bbe8b90e99..48b509f2b6 100644 --- a/mayan/apps/common/utils.py +++ b/mayan/apps/common/utils.py @@ -102,9 +102,9 @@ def get_descriptor(file_input, read=True): except AttributeError: # If not, try open it. if read: - return open(file_input, 'rb') + return open(file_input, mode='rb') else: - return open(file_input, 'wb') + return open(file_input, mode='wb') else: return file_input diff --git a/mayan/apps/django_gpg/tests/test_models.py b/mayan/apps/django_gpg/tests/test_models.py index 80718550df..99261d9a5f 100644 --- a/mayan/apps/django_gpg/tests/test_models.py +++ b/mayan/apps/django_gpg/tests/test_models.py @@ -86,7 +86,7 @@ class KeyTestCase(BaseTestCase): cleartext_file.close() def test_embedded_verification_no_key(self): - with open(TEST_SIGNED_FILE, 'rb') as signed_file: + with open(TEST_SIGNED_FILE, mode='rb') as signed_file: result = Key.objects.verify_file(signed_file) self.assertTrue(result.key_id in TEST_KEY_FINGERPRINT) @@ -94,7 +94,7 @@ class KeyTestCase(BaseTestCase): def test_embedded_verification_with_key(self): Key.objects.create(key_data=TEST_KEY_DATA) - with open(TEST_SIGNED_FILE, 'rb') as signed_file: + with open(TEST_SIGNED_FILE, mode='rb') as signed_file: result = Key.objects.verify_file(signed_file) self.assertEqual(result.fingerprint, TEST_KEY_FINGERPRINT) @@ -102,7 +102,7 @@ class KeyTestCase(BaseTestCase): def test_embedded_verification_with_correct_fingerprint(self): Key.objects.create(key_data=TEST_KEY_DATA) - with open(TEST_SIGNED_FILE, 'rb') as signed_file: + with open(TEST_SIGNED_FILE, mode='rb') as signed_file: result = Key.objects.verify_file( signed_file, key_fingerprint=TEST_KEY_FINGERPRINT ) @@ -113,14 +113,14 @@ class KeyTestCase(BaseTestCase): def test_embedded_verification_with_incorrect_fingerprint(self): Key.objects.create(key_data=TEST_KEY_DATA) - with open(TEST_SIGNED_FILE, 'rb') as signed_file: + with open(TEST_SIGNED_FILE, mode='rb') as signed_file: with self.assertRaises(KeyDoesNotExist): Key.objects.verify_file(signed_file, key_fingerprint='999') def test_signed_file_decryption(self): Key.objects.create(key_data=TEST_KEY_DATA) - with open(TEST_SIGNED_FILE, 'rb') as signed_file: + with open(TEST_SIGNED_FILE, mode='rb') as signed_file: result = Key.objects.decrypt_file(file_object=signed_file) self.assertEqual(result.read(), TEST_SIGNED_FILE_CONTENT) @@ -136,8 +136,8 @@ class KeyTestCase(BaseTestCase): cleartext_file.close() def test_detached_verification_no_key(self): - with open(TEST_DETACHED_SIGNATURE, 'rb') as signature_file: - with open(TEST_FILE, 'rb') as test_file: + with open(TEST_DETACHED_SIGNATURE, mode='rb') as signature_file: + with open(TEST_FILE, mode='rb') as test_file: result = Key.objects.verify_file( file_object=test_file, signature_file=signature_file ) @@ -147,8 +147,8 @@ class KeyTestCase(BaseTestCase): def test_detached_verification_with_key(self): Key.objects.create(key_data=TEST_KEY_DATA) - with open(TEST_DETACHED_SIGNATURE, 'rb') as signature_file: - with open(TEST_FILE, 'rb') as test_file: + with open(TEST_DETACHED_SIGNATURE, mode='rb') as signature_file: + with open(TEST_FILE, mode='rb') as test_file: result = Key.objects.verify_file( file_object=test_file, signature_file=signature_file ) @@ -160,7 +160,7 @@ class KeyTestCase(BaseTestCase): key = Key.objects.create(key_data=TEST_KEY_DATA) with self.assertRaises(NeedPassphrase): - with open(TEST_FILE, 'rb') as test_file: + with open(TEST_FILE, mode='rb') as test_file: key.sign_file( file_object=test_file, detached=True, ) @@ -169,7 +169,7 @@ class KeyTestCase(BaseTestCase): key = Key.objects.create(key_data=TEST_KEY_DATA) with self.assertRaises(PassphraseError): - with open(TEST_FILE, 'rb') as test_file: + with open(TEST_FILE, mode='rb') as test_file: key.sign_file( file_object=test_file, detached=True, passphrase='bad passphrase' @@ -178,7 +178,7 @@ class KeyTestCase(BaseTestCase): def test_detached_signing_with_passphrase(self): key = Key.objects.create(key_data=TEST_KEY_DATA) - with open(TEST_FILE, 'rb') as test_file: + with open(TEST_FILE, mode='rb') as test_file: detached_signature = key.sign_file( file_object=test_file, detached=True, passphrase=TEST_KEY_PASSPHRASE @@ -188,7 +188,7 @@ class KeyTestCase(BaseTestCase): signature_file.write(force_bytes(detached_signature)) signature_file.seek(0) - with open(TEST_FILE, 'rb') as test_file: + with open(TEST_FILE, mode='rb') as test_file: result = Key.objects.verify_file( file_object=test_file, signature_file=signature_file ) diff --git a/mayan/apps/document_signatures/managers.py b/mayan/apps/document_signatures/managers.py index 050eaf8f20..edebf7c763 100644 --- a/mayan/apps/document_signatures/managers.py +++ b/mayan/apps/document_signatures/managers.py @@ -40,7 +40,7 @@ class EmbeddedSignatureManager(models.Manager): except Exception: raise else: - with open(temporary_filename, 'rb') as file_object: + with open(temporary_filename, mode='rb') as file_object: new_version = document_version.document.new_version( file_object=file_object, _user=user ) diff --git a/mayan/apps/document_states/tests/test_api.py b/mayan/apps/document_states/tests/test_api.py index 1720ce5c21..97f6340679 100644 --- a/mayan/apps/document_states/tests/test_api.py +++ b/mayan/apps/document_states/tests/test_api.py @@ -38,7 +38,7 @@ class WorkflowAPITestCase(BaseAPITestCase): label=TEST_DOCUMENT_TYPE_LABEL ) - with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_object: + with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object: self.document = self.document_type.new_document( file_object=file_object ) @@ -372,7 +372,7 @@ class WorkflowStatesAPITestCase(BaseAPITestCase): label=TEST_DOCUMENT_TYPE_LABEL ) - with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_object: + with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object: self.document = self.document_type.new_document( file_object=file_object ) @@ -548,7 +548,7 @@ class WorkflowTransitionsAPITestCase(BaseAPITestCase): label=TEST_DOCUMENT_TYPE_LABEL ) - with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_object: + with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object: self.document = self.document_type.new_document( file_object=file_object ) @@ -790,7 +790,7 @@ class DocumentWorkflowsAPITestCase(BaseAPITestCase): super(DocumentWorkflowsAPITestCase, self).tearDown() def _create_document(self): - with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_object: + with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object: self.document = self.document_type.new_document( file_object=file_object ) diff --git a/mayan/apps/document_states/tests/test_models.py b/mayan/apps/document_states/tests/test_models.py index 21c0a97fb0..91fc868896 100644 --- a/mayan/apps/document_states/tests/test_models.py +++ b/mayan/apps/document_states/tests/test_models.py @@ -30,7 +30,7 @@ class DocumentStateIndexingTestCase(BaseTestCase): ) def _create_document(self): - with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_object: + with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object: self.document = self.document_type.new_document( file_object=file_object ) diff --git a/mayan/apps/documents/models.py b/mayan/apps/documents/models.py index 3db0fe854d..f5b973e01d 100644 --- a/mayan/apps/documents/models.py +++ b/mayan/apps/documents/models.py @@ -529,7 +529,7 @@ class DocumentVersion(models.Model): converter = converter_class(file_object=self.open()) pdf_file_object = converter.to_pdf() - with storage_documentimagecache.open(cache_filename, 'wb+') as file_object: + with storage_documentimagecache.open(cache_filename, mode='wb+') as file_object: for chunk in pdf_file_object: file_object.write(chunk) diff --git a/mayan/apps/linking/tests/test_api.py b/mayan/apps/linking/tests/test_api.py index 2efdac2aa7..90fb862bc2 100644 --- a/mayan/apps/linking/tests/test_api.py +++ b/mayan/apps/linking/tests/test_api.py @@ -207,7 +207,7 @@ class SmartLinkConditionAPITestCase(BaseAPITestCase): ) def _create_document(self): - with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_object: + with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object: self.document = self.document_type.new_document( file_object=file_object ) diff --git a/mayan/apps/metadata/tests/test_api.py b/mayan/apps/metadata/tests/test_api.py index fc7d45a6a9..1bca004022 100644 --- a/mayan/apps/metadata/tests/test_api.py +++ b/mayan/apps/metadata/tests/test_api.py @@ -354,7 +354,7 @@ class DocumentMetadataAPITestCase(BaseAPITestCase): metadata_type=self.metadata_type, required=False ) - with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_object: + with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object: self.document = self.document_type.new_document( file_object=file_object, ) diff --git a/mayan/apps/metadata/tests/test_views.py b/mayan/apps/metadata/tests/test_views.py index c0c2d5a787..edff891e06 100644 --- a/mayan/apps/metadata/tests/test_views.py +++ b/mayan/apps/metadata/tests/test_views.py @@ -201,7 +201,7 @@ class DocumentMetadataTestCase(GenericDocumentViewTestCase): self.grant_permission(permission=permission_metadata_document_add) self.grant_permission(permission=permission_metadata_document_edit) - with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_object: + with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object: document_2 = self.document_type.new_document( file_object=File(file_object) ) @@ -247,7 +247,7 @@ class DocumentMetadataTestCase(GenericDocumentViewTestCase): self.grant_permission(permission=permission_document_view) self.grant_permission(permission=permission_metadata_document_remove) - with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_object: + with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object: document_2 = self.document_type.new_document( file_object=File(file_object) ) @@ -289,7 +289,7 @@ class DocumentMetadataTestCase(GenericDocumentViewTestCase): self.grant_permission(permission=permission_metadata_document_add) self.grant_permission(permission=permission_metadata_document_edit) - with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_object: + with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object: document_2 = self.document_type.new_document( file_object=File(file_object) ) diff --git a/mayan/apps/sources/tests/test_views.py b/mayan/apps/sources/tests/test_views.py index abe2490e8d..98c8cabc8c 100644 --- a/mayan/apps/sources/tests/test_views.py +++ b/mayan/apps/sources/tests/test_views.py @@ -142,7 +142,7 @@ class DocumentUploadIssueTestCase(GenericViewTestCase): self.assertEqual(WebFormSource.objects.count(), 1) # Upload the test document - with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_descriptor: + with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_descriptor: self.post( viewname='sources:upload_interactive', data={ 'document-language': 'eng',