From 711a0f3f66f7a5e43b40b1b865210b5a3b6c0ac5 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 16 Nov 2023 21:20:25 +0800 Subject: [PATCH] + added test for kill method --- tests/test_thread.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_thread.py b/tests/test_thread.py index 1d5b18a..99d8cdd 100644 --- a/tests/test_thread.py +++ b/tests/test_thread.py @@ -12,6 +12,11 @@ def _dummy_raiseException(x: Exception, delay: float = 0): time.sleep(delay) raise x +def _dummy_iterative(itemCount: int, pTime: float = 0.1, delay: float = 0): + time.sleep(delay) + for i in range(itemCount): + time.sleep(pTime) + @@ -76,6 +81,16 @@ def test_ignoreAll(): new.join() assert len(new.errors) == 0 +def test_threadKilling(): + """This test is for testing that threads are killed properly""" + new = Thread( + target = _dummy_iterative, + args = [5, 0.1, 0] + ) + new.start() + new.kill(True) + assert not new.is_alive() +