@@ -502,13 +502,89 @@ def test_old(self):
502
502
@maybe_mock_s3
503
503
class IterBucketSingleProcessTest (unittest .TestCase ):
504
504
def setUp (self ):
505
- self .old_flag = smart_open .s3 ._MULTIPROCESSING
505
+ self .old_flag_multi = smart_open .s3 ._MULTIPROCESSING
506
+ # self.old_flag_concurrent = smart_open.s3._CONCURRENT_FUTURES
506
507
smart_open .s3 ._MULTIPROCESSING = False
508
+ # smart_open.s3._CONCURRENT_FUTURES = False
507
509
508
510
ignore_resource_warnings ()
509
511
510
512
def tearDown (self ):
511
- smart_open .s3 ._MULTIPROCESSING = self .old_flag
513
+ smart_open .s3 ._MULTIPROCESSING = self .old_flag_multi
514
+ # smart_open.s3._CONCURRENT_FUTURES = self.old_flag_concurrent
515
+ cleanup_bucket ()
516
+
517
+ def test (self ):
518
+ num_keys = 101
519
+ populate_bucket (num_keys = num_keys )
520
+ keys = list (smart_open .s3 .iter_bucket (BUCKET_NAME ))
521
+ self .assertEqual (len (keys ), num_keys )
522
+
523
+ expected = [('key_%d' % x , b'%d' % x ) for x in range (num_keys )]
524
+ self .assertEqual (sorted (keys ), sorted (expected ))
525
+
526
+
527
+ @maybe_mock_s3
528
+ class IterBucketConcurrentFuturesTest (unittest .TestCase ):
529
+ def setUp (self ):
530
+ self .old_flag_multi = smart_open .s3 ._MULTIPROCESSING
531
+ smart_open .s3 ._MULTIPROCESSING = False
532
+ if not smart_open .s3 ._CONCURRENT_FUTURES :
533
+ self .fail ('Unable to test iter bucket concurrent futures since it is disabled on this machine.' )
534
+
535
+ ignore_resource_warnings ()
536
+
537
+ def tearDown (self ):
538
+ smart_open .s3 ._MULTIPROCESSING = self .old_flag_multi
539
+ cleanup_bucket ()
540
+
541
+ def test (self ):
542
+ num_keys = 101
543
+ populate_bucket (num_keys = num_keys )
544
+ keys = list (smart_open .s3 .iter_bucket (BUCKET_NAME ))
545
+ self .assertEqual (len (keys ), num_keys )
546
+
547
+ expected = [('key_%d' % x , b'%d' % x ) for x in range (num_keys )]
548
+ self .assertEqual (sorted (keys ), sorted (expected ))
549
+
550
+
551
+ @maybe_mock_s3
552
+ class IterBucketMultiprocessingTest (unittest .TestCase ):
553
+ def setUp (self ):
554
+ self .old_flag_concurrent = smart_open .s3 ._CONCURRENT_FUTURES
555
+ smart_open .s3 ._CONCURRENT_FUTURES = False
556
+ if not smart_open .s3 ._MULTIPROCESSING :
557
+ self .fail ('Unable to test iter bucket multiprocessing since it is disabled on this machine.' )
558
+
559
+ ignore_resource_warnings ()
560
+
561
+ def tearDown (self ):
562
+ smart_open .s3 ._CONCURRENT_FUTURES = self .old_flag_concurrent
563
+ cleanup_bucket ()
564
+
565
+ def test (self ):
566
+ num_keys = 101
567
+ populate_bucket (num_keys = num_keys )
568
+ keys = list (smart_open .s3 .iter_bucket (BUCKET_NAME ))
569
+ self .assertEqual (len (keys ), num_keys )
570
+
571
+ expected = [('key_%d' % x , b'%d' % x ) for x in range (num_keys )]
572
+ self .assertEqual (sorted (keys ), sorted (expected ))
573
+
574
+
575
+ @maybe_mock_s3
576
+ class IterBucketSingleProcessTest (unittest .TestCase ):
577
+ def setUp (self ):
578
+ self .old_flag_multi = smart_open .s3 ._MULTIPROCESSING
579
+ self .old_flag_concurrent = smart_open .s3 ._CONCURRENT_FUTURES
580
+ smart_open .s3 ._MULTIPROCESSING = False
581
+ smart_open .s3 ._CONCURRENT_FUTURES = False
582
+
583
+ ignore_resource_warnings ()
584
+
585
+ def tearDown (self ):
586
+ smart_open .s3 ._MULTIPROCESSING = self .old_flag_multi
587
+ smart_open .s3 ._CONCURRENT_FUTURES = self .old_flag_concurrent
512
588
cleanup_bucket ()
513
589
514
590
def test (self ):
0 commit comments