Skip to content
Snippets Groups Projects
Commit 62eb627b authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

coverage+

parent bbd4333f
No related branches found
No related tags found
No related merge requests found
......@@ -38,9 +38,14 @@ class TestConcurrent(unittest.TestCase):
def test_bogus(self):
bt = BogusTerminableThread()
self.assertFalse(bt.is_alive())
self.assertRaises(RuntimeError, bt.join)
bt.start()
self.assertRaises(RuntimeError, bt.start)
self.assertRaises(WouldWaitMore, lambda: bt.join(1))
self.assertTrue(bt.is_alive())
bt.terminate()
self.assertRaises(RuntimeError, bt.start)
bt.join(2)
def test_thread_collection(self):
......@@ -462,6 +467,21 @@ class TestConcurrent(unittest.TestCase):
ml2 = copy.copy(ml)
self.assertEqual(ml2, ml)
def test_terminate_on_exception(self):
class MyThread(TerminableThread):
def __init__(self):
super().__init__(terminate_on=(ValueError, KeyError))
self.a = 0
def loop(self) -> None:
self.a += 1
if self.a == 4:
raise ValueError()
mt = MyThread()
mt.start().join()
mt.terminate()
@unittest.skipUnless(sys.implementation.name == 'cpython', 'Does not work on PyPy :(')
def test_condition(self):
dct = {'a': False}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment