Skip to content

Commit a76318e

Browse files
committed
move self._executor.shutdown to addCleanup
1 parent 23825f4 commit a76318e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Lib/test/test_unittest/testmock/testthreadingmock.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,14 @@ class TestThreadingMockRaceCondition(unittest.TestCase):
204204

205205
def setUp(self):
206206
self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=5)
207+
self.addCleanup(self._executor.shutdown)
207208

208209
# Store and restore original switch interval using addCleanup
209210
self.addCleanup(sys.setswitchinterval, sys.getswitchinterval())
210211

211212
# Set switch interval to minimum to force frequent context switches
212213
sys.setswitchinterval(sys.float_info.min)
213214

214-
def tearDown(self):
215-
self._executor.shutdown()
216-
217215
def test_call_count_race_condition_with_fast_switching(self):
218216
"""Force race condition by maximizing thread context switches.
219217

0 commit comments

Comments
 (0)