Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_s3: Only abort the multipart-upload if it did not complete #2177

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 20 additions & 17 deletions tests/integration/test_s3.py
Expand Up @@ -248,24 +248,27 @@ def test_can_create_object_directly(self):
def test_s3_multipart(self):
# Create the multipart upload
mpu = self.bucket.Object('mp-test.txt').initiate_multipart_upload()
self.addCleanup(mpu.abort)

# Create and upload a part
part = mpu.Part(1)
response = part.upload(Body='hello, world!')

# Complete the upload, which requires info on all of the parts
part_info = {
'Parts': [
{
'PartNumber': 1,
'ETag': response['ETag']
}
]
}
try:
# Create and upload a part
part = mpu.Part(1)
response = part.upload(Body='hello, world!')

# Complete the upload, which requires info on all of the parts
part_info = {
'Parts': [
{
'PartNumber': 1,
'ETag': response['ETag']
}
]
}

mpu.complete(MultipartUpload=part_info)
self.addCleanup(self.bucket.Object('mp-test.txt').delete)
mpu.complete(MultipartUpload=part_info)
except Exception:
self.addCleanup(mpu.abort)
raise
else:
self.addCleanup(self.bucket.Object('mp-test.txt').delete)

contents = self.bucket.Object('mp-test.txt').get()['Body'].read()
self.assertEqual(contents, b'hello, world!')
Expand Down