issue 10237

After increasing the default timeout for the barrier, the unittest for the default timeout must be adjusted
parent cc221b24
...@@ -604,9 +604,10 @@ class BarrierTests(BaseTestCase): ...@@ -604,9 +604,10 @@ class BarrierTests(BaseTestCase):
Tests for Barrier objects. Tests for Barrier objects.
""" """
N = 5 N = 5
defaultTimeout = 0.5
def setUp(self): def setUp(self):
self.barrier = self.barriertype(self.N, timeout=0.5) self.barrier = self.barriertype(self.N, timeout=self.defaultTimeout)
def tearDown(self): def tearDown(self):
self.barrier.abort() self.barrier.abort()
...@@ -775,12 +776,14 @@ class BarrierTests(BaseTestCase): ...@@ -775,12 +776,14 @@ class BarrierTests(BaseTestCase):
""" """
Test the barrier's default timeout Test the barrier's default timeout
""" """
#create a barrier with a low default timeout
barrier = self.barriertype(self.N, timeout=0.1)
def f(): def f():
i = self.barrier.wait() i = barrier.wait()
if i == self.N // 2: if i == self.N // 2:
# One thread is later than the default timeout of 0.1s. # One thread is later than the default timeout of 0.1s.
time.sleep(0.15) time.sleep(0.2)
self.assertRaises(threading.BrokenBarrierError, self.barrier.wait) self.assertRaises(threading.BrokenBarrierError, barrier.wait)
self.run_threads(f) self.run_threads(f)
def test_single_thread(self): def test_single_thread(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment