Skip to content

Commit 7f940c2

Browse files
committed
concurrent/thread: add pool parameter tests
Signed-off-by: Matteo Cafasso <[email protected]>
1 parent 8d4e4dc commit 7f940c2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

test/test_concurrent_thread.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import threading
33

44
from pebble import concurrent
5+
from pebble import ThreadPool
56

67

78
def not_decorated(argument, keyword_argument=0):
@@ -44,6 +45,11 @@ def daemon_keyword_decorated():
4445
return threading.current_thread().daemon
4546

4647

48+
@concurrent.thread(pool=ThreadPool(1))
49+
def pool_decorated(_argument, _keyword_argument=0):
50+
return threading.current_thread().ident
51+
52+
4753
class ThreadConcurrentObj:
4854
a = 0
4955

@@ -130,7 +136,7 @@ def test_error_returned(self):
130136
self.assertIsInstance(future.result(), RuntimeError)
131137

132138
def test_error_decorated_callback(self):
133-
"""Thread errors are forwarded to callback."""
139+
"""Thread errors are forwarded to callback."""
134140
future = error_decorated()
135141
future.add_done_callback(self.callback)
136142
self.event.wait(timeout=1)
@@ -163,3 +169,9 @@ def test_daemon_keyword_decorated(self):
163169
f = daemon_keyword_decorated()
164170
dec_out = f.result()
165171
self.assertEqual(dec_out, False)
172+
173+
def test_pool_decorated(self):
174+
"""Thread pool decorated function."""
175+
future1 = pool_decorated(1, 1)
176+
future2 = pool_decorated(1, 1)
177+
self.assertEqual(future1.result(), future2.result())

0 commit comments

Comments
 (0)