@@ -2118,40 +2118,39 @@ def work():
21182118        truncate  =  getattr (_thread , "_NAME_MAXLEN" , None )
21192119        limit  =  truncate  or  100 
21202120
2121-         def  create_test (name ):
2122-             if  sys .platform .startswith ("solaris" ):
2123-                 encoding  =  "utf-8" 
2124-             else :
2125-                 encoding  =  sys .getfilesystemencoding ()
2126-             encoded  =  name .encode (encoding , "replace" )
2127-             if  truncate  is  not   None :
2128-                 expected  =  os .fsdecode (encoded [:truncate ])
2129-             else :
2130-                 expected  =  os .fsdecode (encoded )
2131-             return  (name , expected )
2132- 
21332121        tests  =  [
21342122            # test short ASCII name 
2135-             create_test ( "CustomName" ) ,
2123+             "CustomName" ,
21362124
21372125            # test short non-ASCII name 
2138-             create_test ( "namé€" ) ,
2126+             "namé€" ,
21392127
21402128            # Test long ASCII names (not truncated) 
2141-             create_test ( "x"  *  limit ) ,
2129+             "x"  *  limit ,
21422130
21432131            # Test long ASCII names (truncated) 
2144-             create_test ( "x"  *  (limit  +  10 ) ),
2132+             "x"  *  (limit  +  10 ),
21452133
21462134            # Test long non-ASCII name (truncated) 
2147-             create_test ( "x"  *  (limit  -  1 ) +  "é€" ) ,
2135+             "x"  *  (limit  -  1 ) +  "é€" ,
21482136        ]
21492137        if  os_helper .FS_NONASCII :
2150-             tests .append (create_test ( f"nonascii:{ os_helper .FS_NONASCII }  " ) )
2138+             tests .append (f"nonascii:{ os_helper .FS_NONASCII }  " )
21512139        if  os_helper .TESTFN_UNENCODABLE :
2152-             tests .append (create_test (os_helper .TESTFN_UNENCODABLE ))
2140+             tests .append (os_helper .TESTFN_UNENCODABLE )
2141+ 
2142+         if  sys .platform .startswith ("solaris" ):
2143+             encoding  =  "utf-8" 
2144+         else :
2145+             encoding  =  sys .getfilesystemencoding ()
2146+ 
2147+         for  name  in  tests :
2148+             encoded  =  name .encode (encoding , "replace" )
2149+             if  truncate  is  not   None :
2150+                 expected  =  os .fsdecode (encoded [:truncate ])
2151+             else :
2152+                 expected  =  os .fsdecode (encoded )
21532153
2154-         for  name , expected  in  tests :
21552154            with  self .subTest (name = name , expected = expected ):
21562155                work_name  =  None 
21572156                thread  =  threading .Thread (target = work , name = name )
0 commit comments