55
66from _context import ezpq
77
8- def return_i ( i = 1 ):
9- return i
8+ def return_me ( x = 1 ):
9+ return x
1010
1111class TestEZPQ (unittest .TestCase ):
1212
1313 def setUp (self ):
14- self .Q = ezpq .Queue (job_runner = Process , auto_start = True )
14+ self .Q = ezpq .Queue (job_runner = Process , auto_start = True , n_workers = 5 )
1515 self .input = tuple (range (100 ))
1616
1717 def test_priority (self ):
1818 self .Q ._stop ()
1919
20- for i in self .input :
21- self .Q .put (function = return_i , args = i ,
22- priority = - i ) # should result in reversed inputs.
20+ for x in self .input :
21+ self .Q .put (function = return_me , args = x ,
22+ priority = - x ) # should result in reversed inputs.
2323
2424 self .Q .start ()
2525 self .Q .wait ()
@@ -29,12 +29,22 @@ def test_priority(self):
2929 self .assertEqual (tuple (reversed (self .input )), out_list )
3030
3131 def test_map (self ):
32- job_data = self .Q .map (function = return_i , iterable = self .input , ordered = True )
32+ job_data = self .Q .map (function = return_me , iterable = self .input )
3333
3434 out_list = tuple (job ['output' ] for job in job_data )
3535
3636 self .assertEqual (self .input , out_list )
3737
38+ def test_lanes (self ):
39+ for i , x in enumerate (self .input ):
40+ self .Q .put (function = return_me , args = x ,
41+ lane = i % self .Q .n_workers ()) # returns in order
42+
43+ self .Q .wait ()
44+ out_list = tuple (x ['output' ] for x in self .Q .collect ())
45+
46+ self .assertEqual (self .input , out_list )
47+
3848 def test_size (self ):
3949 self .assertEqual (self .Q .size (), 0 )
4050
0 commit comments