Tests should clearly communicate their purpose and expectations without requiring readers to analyze implementation details or scroll through files. Each test should:
Tests should clearly communicate their purpose and expectations without requiring readers to analyze implementation details or scroll through files. Each test should:
Example of a poorly documented test:
def test_upload(self):
transfer = self.create_s3_transfer()
filename = self.files.create_file_with_size('foo.txt', 1024 * 1024)
transfer.upload_file(filename, self.bucket_name, 'foo.txt')
self.assertTrue(self.object_exists('foo.txt'))
Improved version:
def test_upload_below_threshold_uses_single_part_upload(self):
# Configure transfer to use single-part for small files
config = TransferConfig(multipart_threshold=5 * 1024 * 1024)
transfer = self.create_s3_transfer(config)
# Create a 1MB file (below threshold)
filename = self.files.create_file_with_size('foo.txt', 1024 * 1024)
# Upload should use single-part upload
transfer.upload_file(filename, self.bucket_name, 'foo.txt')
# Verify file exists and was uploaded as single part
self.assertTrue(self.object_exists('foo.txt'))
self.assertEqual(self.get_upload_type('foo.txt'), 'SINGLE_PART')
The improved version:
Enter the URL of a public GitHub repository