File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Lib/test/test_unittest/testmock Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -199,16 +199,17 @@ def test_reset_mock_resets_wait(self):
199199 m .assert_called_once ()
200200
201201 def test_call_count_thread_safe (self ):
202+ # See https://github.com/python/cpython/issues/142651.
203+ m = ThreadingMock ()
204+ LOOPS = 100
205+ THREADS = 10
206+ def test_function ():
207+ for _ in range (LOOPS ):
208+ m ()
209+
202210 oldswitchinterval = sys .getswitchinterval ()
203211 setswitchinterval (1e-6 )
204212 try :
205- m = ThreadingMock ()
206- # 100 loops with 10 threads reliably reproduces the issue while keeping runtime ~0.2s
207- LOOPS = 100
208- THREADS = 10
209- def test_function ():
210- for _ in range (LOOPS ):
211- m ()
212213 threads = [threading .Thread (target = test_function ) for _ in range (THREADS )]
213214 for thread in threads :
214215 thread .start ()
You can’t perform that action at this time.
0 commit comments