-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_job_queue.py
62 lines (48 loc) · 1.23 KB
/
test_job_queue.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from nose.tools import *
from job_queue import Job_Queue
from multiprocessing import Process
def test_init():
jobs = Job_Queue(5)
assert_equal(jobs._queued, [])
assert_equal(jobs._running, [])
assert_equal(jobs._completed, [])
assert_equal(jobs._num_of_jobs, 0)
assert_equal(jobs._max, 5)
assert_false(jobs._finished)
assert_false(jobs._closed)
assert_false(jobs._debug)
jobs._debug = True
assert_true(jobs._debug)
def populate():
jobs = Job_Queue(5)
def foo():
return 10
for x in range(10):
jobs.append(Process(
target = foo,
args = [],
kwargs = {},
))
return jobs
@raises(Exception)
def test_some():
jobs = populate()
jobs.start()
def test_length():
jobs = populate()
assert_equal( jobs._num_of_jobs, 10)
assert_equal( len(jobs._queued), 10)
assert_equal(len(jobs), 10)
def test_closed():
jobs = populate()
assert_false(jobs._closed)
jobs.close()
assert_true(jobs._closed)
def test_runs():
jobs = populate()
jobs.close()
assert_false(jobs._finished)
jobs.start()
assert_true(jobs._finished)
assert_false(jobs._all_alive())
assert_equal(jobs._running,[])