Add explicit argument name of 'mode' to the open statement.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-10-31 16:53:48 -04:00
parent 5a8455bfc2
commit 9fc7c4fc09
11 changed files with 33 additions and 33 deletions

View File

@@ -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(

View File

@@ -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

View File

@@ -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
)

View File

@@ -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
)

View File

@@ -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
)

View File

@@ -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
)

View File

@@ -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)

View File

@@ -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
)

View File

@@ -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,
)

View File

@@ -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)
)

View File

@@ -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',