Skip to content

Commit 711a0f3

Browse files
+ added test for kill method
1 parent 41c8678 commit 711a0f3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_thread.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ def _dummy_raiseException(x: Exception, delay: float = 0):
1212
time.sleep(delay)
1313
raise x
1414

15+
def _dummy_iterative(itemCount: int, pTime: float = 0.1, delay: float = 0):
16+
time.sleep(delay)
17+
for i in range(itemCount):
18+
time.sleep(pTime)
19+
1520

1621

1722

@@ -76,6 +81,16 @@ def test_ignoreAll():
7681
new.join()
7782
assert len(new.errors) == 0
7883

84+
def test_threadKilling():
85+
"""This test is for testing that threads are killed properly"""
86+
new = Thread(
87+
target = _dummy_iterative,
88+
args = [5, 0.1, 0]
89+
)
90+
new.start()
91+
new.kill(True)
92+
assert not new.is_alive()
93+
7994

8095

8196

0 commit comments

Comments
 (0)