File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2281,6 +2281,9 @@ def test__all__(self):
22812281 @unittest .skipUnless (hasattr (_thread , 'set_name' ), "missing _thread.set_name" )
22822282 @unittest .skipUnless (hasattr (_thread , '_get_name' ), "missing _thread._get_name" )
22832283 def test_set_name (self ):
2284+ # Ensure main thread name is restored after test
2285+ self .addCleanup (_thread .set_name , _thread ._get_name ())
2286+
22842287 # set_name() limit in bytes
22852288 truncate = getattr (_thread , "_NAME_MAXLEN" , None )
22862289 limit = truncate or 100
@@ -2356,9 +2359,6 @@ def work():
23562359 if '\0 ' in expected :
23572360 expected = expected .split ('\0 ' , 1 )[0 ]
23582361
2359- # Ensure main thread name is restored after test
2360- self .addCleanup (_thread .set_name , _thread ._get_name ())
2361-
23622362 with self .subTest (name = name , expected = expected , thread = "main" ):
23632363 _thread .set_name (name )
23642364 self .assertEqual (_thread ._get_name (), expected )
You can’t perform that action at this time.
0 commit comments