-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtest_threadutil.py
More file actions
44 lines (33 loc) · 1.09 KB
/
test_threadutil.py
File metadata and controls
44 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""threading utilities unit tests."""
import time
import threading
from splitio.util.threadutil import EventGroup
class EventGroupTests(object):
"""EventGroup class test cases."""
def test_basic_functionality(self):
"""Test basic functionality."""
def fun(event): #pylint:disable=missing-docstring
time.sleep(1)
event.set()
group = EventGroup()
event1 = group.make_event()
event2 = group.make_event()
task = threading.Thread(target=fun, args=(event1,))
task.start()
group.wait(3)
assert event1.is_set()
assert not event2.is_set()
group = EventGroup()
event1 = group.make_event()
event2 = group.make_event()
task = threading.Thread(target=fun, args=(event2,))
task.start()
group.wait(3)
assert not event1.is_set()
assert event2.is_set()
group = EventGroup()
event1 = group.make_event()
event2 = group.make_event()
group.wait(3)
assert not event1.is_set()
assert not event2.is_set()