Skip to content

Commit 3b29867

Browse files
committed
update according to comments
1 parent 851f698 commit 3b29867

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Lib/test/test_unittest/testmock/testthreadingmock.py

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

0 commit comments

Comments
 (0)