@@ -107,8 +107,9 @@ def tearDown(self):
107107 self .sess .cleanup ()
108108
109109 @staticmethod
110- def In_Memory_Stream ():
111- return io .BytesIO () if sys .version_info < (3 ,) else io .StringIO ()
110+ def In_Memory_Stream (always_unicode = False ):
111+ return io .StringIO () if sys .version_info >= (3 ,) or always_unicode \
112+ else io .BytesIO ()
112113
113114
114115 @contextlib .contextmanager
@@ -318,9 +319,9 @@ def test_put_get_parallel_autoswitch_A__235(self):
318319 options = { kw .DEST_RESC_NAME_KW :Root ,
319320 kw .RESC_NAME_KW :Root }
320321
321- PUT_LOG = self .In_Memory_Stream ()
322- GET_LOG = self .In_Memory_Stream ()
323- NumThreadsRegex = re .compile ('^num_threads\s*=\s*(\d+)' ,re .MULTILINE )
322+ PUT_LOG = self .In_Memory_Stream (always_unicode = True )
323+ GET_LOG = self .In_Memory_Stream (always_unicode = True )
324+ NumThreadsRegex = re .compile (u '^num_threads\s*=\s*(\d+)' ,re .MULTILINE )
324325
325326 try :
326327 logger = logging .getLogger ('irods.parallel' )
@@ -830,7 +831,7 @@ def do_test_redirect_in_data_object_put_and_get__issue_452(self, content, data_c
830831 data_ctx ['initialize' ]()
831832 sess = data_ctx ['session' ]
832833 remote_name = data_ctx ['path' ]
833- PUT_LOG = self .In_Memory_Stream ()
834+ PUT_LOG = self .In_Memory_Stream (always_unicode = True )
834835 with helpers .enableLogging (logging .getLogger ('irods.manager.data_object_manager' ),
835836 logging .StreamHandler , (PUT_LOG ,), level_ = logging .DEBUG ),\
836837 helpers .enableLogging (logging .getLogger ('irods.parallel' ),
@@ -839,11 +840,11 @@ def do_test_redirect_in_data_object_put_and_get__issue_452(self, content, data_c
839840 def srch (BUF ):
840841 nthr = 0
841842 search_text = BUF .getvalue ()
842- find_iterator = itertools .chain ( re .finditer ('redirect_to_host = (\S+)' , search_text ),
843- re .finditer ('target_host = (\S+)' , search_text ) )
843+ find_iterator = itertools .chain ( re .finditer (u 'redirect_to_host = (\S+)' , search_text ),
844+ re .finditer (u 'target_host = (\S+)' , search_text ) )
844845 for match in find_iterator :
845846 nthr += 1
846- self .assertEqual (match .group (1 ), 'localhost' )
847+ self .assertEqual (match .group (1 ), u 'localhost' )
847848 occur_threshold = (1 if len (content ) <= 32 * MEBI else 2 )
848849 self .assertGreaterEqual (nthr , occur_threshold )
849850 srch (PUT_LOG )
@@ -858,7 +859,7 @@ def srch(BUF):
858859 data_ctx_get = next (generator )
859860 data_ctx_get ['initialize' ]()
860861 sess = data_ctx_get ['session' ]
861- GET_LOG = self .In_Memory_Stream ()
862+ GET_LOG = self .In_Memory_Stream (always_unicode = True )
862863 with helpers .enableLogging (logging .getLogger ('irods.manager.data_object_manager' ),
863864 logging .StreamHandler , (GET_LOG ,), level_ = logging .DEBUG ),\
864865 helpers .enableLogging (logging .getLogger ('irods.parallel' ),
@@ -2097,6 +2098,7 @@ def test_touch_operation_does_not_work_when_given_a_collection__525(self):
20972098 with self .assertRaises (ex .InvalidInputArgument ):
20982099 user_session .data_objects .touch (home_collection_path )
20992100
2101+ @unittest .skipIf (six .PY2 , "Python2 won't destruct an out-of-scope iRODSSession due to lazy GC ref-cycle detection." )
21002102 def test_client_redirect_lets_go_of_connections__issue_562 (self ):
21012103 self ._skip_unless_connected_to_local_computer_by_other_than_localhost_synonym ()
21022104 # Force data object connections to redirect by enforcing a non-equivalent hostname for their resource
0 commit comments