1010# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 
1111# ANY KIND, either express or implied. See the License for the specific 
1212# language governing permissions and limitations under the License. 
13+ import  pytest 
14+ 
1315from  tests  import  unittest 
1416
1517import  botocore 
@@ -26,36 +28,26 @@ class TestS3MethodInjection(unittest.TestCase):
2628 def  test_transfer_methods_injected_to_client (self ):
2729 session  =  boto3 .session .Session (region_name = 'us-west-2' )
2830 client  =  session .client ('s3' )
29-  self .assertTrue (hasattr (client , 'upload_file' ),
30-  'upload_file was not injected onto S3 client' )
31-  self .assertTrue (hasattr (client , 'download_file' ),
32-  'download_file was not injected onto S3 client' )
33-  self .assertTrue (hasattr (client , 'copy' ),
34-  'copy was not injected onto S3 client' )
31+  assert  hasattr (client , 'upload_file' )
32+  assert  hasattr (client , 'download_file' )
33+  assert  hasattr (client , 'copy' )
3534
3635 def  test_bucket_resource_has_load_method (self ):
3736 session  =  boto3 .session .Session (region_name = 'us-west-2' )
3837 bucket  =  session .resource ('s3' ).Bucket ('fakebucket' )
39-  self .assertTrue (hasattr (bucket , 'load' ),
40-  'load() was not injected onto S3 Bucket resource.' )
38+  assert  hasattr (bucket , 'load' )
4139
4240 def  test_transfer_methods_injected_to_bucket (self ):
4341 bucket  =  boto3 .resource ('s3' ).Bucket ('my_bucket' )
44-  self .assertTrue (hasattr (bucket , 'upload_file' ),
45-  'upload_file was not injected onto S3 bucket' )
46-  self .assertTrue (hasattr (bucket , 'download_file' ),
47-  'download_file was not injected onto S3 bucket' )
48-  self .assertTrue (hasattr (bucket , 'copy' ),
49-  'copy was not injected onto S3 bucket' )
42+  assert  hasattr (bucket , 'upload_file' )
43+  assert  hasattr (bucket , 'download_file' )
44+  assert  hasattr (bucket , 'copy' )
5045
5146 def  test_transfer_methods_injected_to_object (self ):
5247 obj  =  boto3 .resource ('s3' ).Object ('my_bucket' , 'my_key' )
53-  self .assertTrue (hasattr (obj , 'upload_file' ),
54-  'upload_file was not injected onto S3 object' )
55-  self .assertTrue (hasattr (obj , 'download_file' ),
56-  'download_file was not injected onto S3 object' )
57-  self .assertTrue (hasattr (obj , 'copy' ),
58-  'copy was not injected onto S3 object' )
48+  assert  hasattr (obj , 'upload_file' )
49+  assert  hasattr (obj , 'download_file' )
50+  assert  hasattr (obj , 'copy' )
5951
6052
6153class  BaseTransferTest (unittest .TestCase ):
@@ -208,22 +200,22 @@ def test_client_copy(self):
208200 response  =  self .s3 .meta .client .copy (
209201 self .copy_source , self .bucket , self .key )
210202 # The response will be none on a successful transfer. 
211-  self . assertIsNone ( response ) 
203+  assert   response   is   None 
212204
213205 def  test_bucket_copy (self ):
214206 self .stub_single_part_copy ()
215207 bucket  =  self .s3 .Bucket (self .bucket )
216208 with  self .stubber :
217209 response  =  bucket .copy (self .copy_source , self .key )
218210 # The response will be none on a successful transfer. 
219-  self . assertIsNone ( response ) 
211+  assert   response   is   None 
220212
221213 def  test_object_copy (self ):
222214 self .stub_single_part_copy ()
223215 obj  =  self .s3 .Object (self .bucket , self .key )
224216 with  self .stubber :
225217 response  =  obj .copy (self .copy_source )
226-  self . assertIsNone ( response ) 
218+  assert   response   is   None 
227219
228220 def  test_copy_progress (self ):
229221 chunksize  =  8  *  (1024  **  2 )
@@ -243,8 +235,8 @@ def progress_callback(amount):
243235
244236 # Assert that the progress callback was called the correct number of 
245237 # times with the correct amounts. 
246-  self .assertEqual ( self . progress_times_called ,  3 ) 
247-  self .assertEqual ( self . progress ,  chunksize  *  3 ) 
238+  assert   self .progress_times_called   ==   3 
239+  assert   self .progress   ==   chunksize  *  3 
248240
249241
250242class  TestUploadFileobj (BaseTransferTest ):
@@ -310,7 +302,7 @@ def test_client_upload(self):
310302
311303 def  test_raises_value_error_on_invalid_fileobj (self ):
312304 with  self .stubber :
313-  with  self . assertRaises (ValueError ):
305+  with  pytest . raises (ValueError ):
314306 self .s3 .meta .client .upload_fileobj (
315307 Fileobj = 'foo' , Bucket = self .bucket , Key = self .key )
316308
@@ -427,12 +419,12 @@ def test_client_download(self):
427419 self .s3 .meta .client .download_fileobj (
428420 Bucket = self .bucket , Key = self .key , Fileobj = self .fileobj )
429421
430-  self .assertEqual ( self . fileobj .getvalue (),  self .contents ) 
422+  assert   self .fileobj .getvalue ()  ==   self .contents 
431423 self .stubber .assert_no_pending_responses ()
432424
433425 def  test_raises_value_error_on_invalid_fileobj (self ):
434426 with  self .stubber :
435-  with  self . assertRaises (ValueError ):
427+  with  pytest . raises (ValueError ):
436428 self .s3 .meta .client .download_fileobj (
437429 Bucket = self .bucket , Key = self .key , Fileobj = 'foo' )
438430
@@ -442,7 +434,7 @@ def test_bucket_download(self):
442434 with  self .stubber :
443435 bucket .download_fileobj (Key = self .key , Fileobj = self .fileobj )
444436
445-  self .assertEqual ( self . fileobj .getvalue (),  self .contents ) 
437+  assert   self .fileobj .getvalue ()  ==   self .contents 
446438 self .stubber .assert_no_pending_responses ()
447439
448440 def  test_object_download (self ):
@@ -451,7 +443,7 @@ def test_object_download(self):
451443 with  self .stubber :
452444 obj .download_fileobj (Fileobj = self .fileobj )
453445
454-  self .assertEqual ( self . fileobj .getvalue (),  self .contents ) 
446+  assert   self .fileobj .getvalue ()  ==   self .contents 
455447 self .stubber .assert_no_pending_responses ()
456448
457449 def  test_multipart_download (self ):
@@ -467,7 +459,7 @@ def test_multipart_download(self):
467459 Bucket = self .bucket , Key = self .key , Fileobj = self .fileobj ,
468460 Config = transfer_config )
469461
470-  self .assertEqual ( self . fileobj .getvalue (),  self .contents ) 
462+  assert   self .fileobj .getvalue ()  ==   self .contents 
471463 self .stubber .assert_no_pending_responses ()
472464
473465 def  test_download_progress (self ):
@@ -489,8 +481,8 @@ def progress_callback(amount):
489481
490482 # Assert that the progress callback was called the correct number of 
491483 # times with the correct amounts. 
492-  self .assertEqual ( self . progress_times_called ,  11 ) 
493-  self .assertEqual ( self . progress ,  55 ) 
484+  assert   self .progress_times_called   ==   11 
485+  assert   self .progress   ==   55 
494486 self .stubber .assert_no_pending_responses ()
495487
496488
@@ -520,19 +512,19 @@ def tearDown(self):
520512 self .stubber .deactivate ()
521513
522514 def  test_has_load (self ):
523-  self . assertTrue ( hasattr ( self . obj_summary ,  ' load' ), 
524-    'load() was not injected onto ObjectSummary resource. ' )
515+  # Validate  load was injected onto ObjectSummary. 
516+  assert   hasattr ( self . obj_summary ,  'load' )
525517
526518 def  test_autoloads_correctly (self ):
527519 # In HeadObject the parameter returned is ContentLength, this 
528520 # should get mapped to Size of ListObject since the resource uses 
529521 # the shape returned to by ListObjects. 
530-  self .assertEqual ( self . obj_summary .size ,  self .obj_summary_size ) 
522+  assert   self .obj_summary .size   ==   self .obj_summary_size 
531523
532524 def  test_cannot_access_other_non_related_parameters (self ):
533525 # Even though an HeadObject was used to load this, it should 
534526 # only expose the attributes from its shape defined in ListObjects. 
535-  self . assertFalse ( hasattr (self .obj_summary , 'content_length' ) )
527+  assert   not   hasattr (self .obj_summary , 'content_length' )
536528
537529
538530class  TestServiceResource (unittest .TestCase ):
@@ -542,7 +534,5 @@ def setUp(self):
542534 def  test_unsigned_signature_version_is_not_corrupted (self ):
543535 config  =  Config (signature_version = botocore .UNSIGNED )
544536 resource  =  self .session .resource ('s3' , config = config )
545-  self .assertIs (
546-  resource .meta .client .meta .config .signature_version ,
547-  botocore .UNSIGNED 
548-  )
537+  sig_version  =  resource .meta .client .meta .config .signature_version 
538+  assert  sig_version  is  botocore .UNSIGNED 
0 commit comments