Skip to content

Commit 5e5effb

Browse files
committed
revert name reset to original position
1 parent 8fc613b commit 5e5effb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/test/test_threading.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)