示例#1
0
 def testFailure(self):
     self.assertRaises(ZeroDivisionError, list, flow.Block(badgen()))
     self.assertEqual(['x',ZeroDivisionError],
                      list(flow.Block(badgen(),ZeroDivisionError)))
     self.assertEqual(['x',ZeroDivisionError],
                      list(flow.Block(flow.wrap(badgen()),
                                                ZeroDivisionError)))
示例#2
0
 def testLineBreak(self):
     lhs = [ "Hello World", "Happy Days Are Here" ]
     rhs = ["Hello ","World\nHappy", flow.Cooperate(),
            " Days"," Are Here\n"]
     mrg = flow.LineBreak(slowlist(rhs), delimiter='\n')
     rhs = list(flow.Block(mrg))
     self.assertEqual(lhs,rhs)
示例#3
0
 def testFilter(self):
     def odd(val):
         if val % 2:
             return True
     lhs = [ 1, 3 ]
     mrg = flow.Filter(odd,slowlist([1,2,flow.Cooperate(),3]))
     rhs = list(flow.Block(mrg))
     self.assertEqual(lhs,rhs)
示例#4
0
 def testDeferredWrapperImmediate(self):
     from twisted.internet import defer
     a = defer.Deferred()
     a.callback("test")
     self.assertEquals(["test"], list(flow.Block(a)))
示例#5
0
 def testBuildList(self):
     src = flow.wrap([1,2,3])
     out = flow.Block(buildlist(src)).next()
     self.assertEquals(out,[1,2,3])
示例#6
0
 def testMerge(self):
     lhs = ['one', 1, 'two', 2, 3, 'three']
     mrg = flow.Merge(slowlist(_onetwothree),slowlist([1,2,3]))
     rhs = list(flow.Block(mrg))
     self.assertEqual(lhs,rhs)
示例#7
0
 def testZip(self):
     lhs = [(1,'a'),(2,'b'),(3,None)]
     mrg = flow.Zip([1,2,flow.Cooperate(),3],['a','b'])
     rhs = list(flow.Block(mrg))
     self.assertEqual(lhs,rhs)
示例#8
0
 def testConsumer(self):
     lhs = ['Title',(1,'one'),(2,'two'),(3,'three')]
     rhs = list(flow.Block(consumer))
     self.assertEqual(lhs,rhs)
示例#9
0
 def testProducer(self):
     lhs = [(1,'one'),(2,'two'),(3,'three')]
     rhs = list(flow.Block(producer()))
     self.assertEqual(lhs,rhs)
示例#10
0
 def testCallable(self):
     lhs = ['one','two','three']
     rhs = list(flow.Block(slowlist(_onetwothree)))
     self.assertEqual(lhs,rhs)
示例#11
0
 def testBasicIterator(self):
     lhs = ['one','two','three']
     rhs = list(flow.Block(slowlist(_onetwothree)))
     self.assertEqual(lhs,rhs)
示例#12
0
 def testBasicList(self):
     lhs = [1,2,3]
     rhs = list(flow.Block([1,2,flow.Cooperate(),3]))
     self.assertEqual(lhs,rhs)
示例#13
0
 def testBasic(self):
     lhs = ['string']
     rhs = list(flow.Block('string'))
     self.assertEqual(lhs,rhs)