Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f53a626

Browse files
author
Kristján Valur Jónsson
committed
issue 10237
After increasing the default timeout for the barrier, the unittest for the default timeout must be adjusted
1 parent cc221b2 commit f53a626

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Lib/test/lock_tests.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,10 @@ class BarrierTests(BaseTestCase):
604604
Tests for Barrier objects.
605605
"""
606606
N = 5
607+
defaultTimeout = 0.5
607608

608609
def setUp(self):
609-
self.barrier = self.barriertype(self.N, timeout=0.5)
610+
self.barrier = self.barriertype(self.N, timeout=self.defaultTimeout)
610611
def tearDown(self):
611612
self.barrier.abort()
612613

@@ -775,12 +776,14 @@ def test_default_timeout(self):
775776
"""
776777
Test the barrier's default timeout
777778
"""
779+
#create a barrier with a low default timeout
780+
barrier = self.barriertype(self.N, timeout=0.1)
778781
def f():
779-
i = self.barrier.wait()
782+
i = barrier.wait()
780783
if i == self.N // 2:
781784
# One thread is later than the default timeout of 0.1s.
782-
time.sleep(0.15)
783-
self.assertRaises(threading.BrokenBarrierError, self.barrier.wait)
785+
time.sleep(0.2)
786+
self.assertRaises(threading.BrokenBarrierError, barrier.wait)
784787
self.run_threads(f)
785788

786789
def test_single_thread(self):

0 commit comments

Comments
 (0)