From 62eb627b9480eecbc873355d67e02ddd79f5dd48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Fri, 4 Jun 2021 22:57:41 +0200
Subject: [PATCH] coverage+

---
 tests/test_coding/test_concurrent.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/test_coding/test_concurrent.py b/tests/test_coding/test_concurrent.py
index 1624c67c..49db4072 100644
--- a/tests/test_coding/test_concurrent.py
+++ b/tests/test_coding/test_concurrent.py
@@ -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}
-- 
GitLab