Exemplo n.º 1
0
 def test_basic_receive(self):
   i = IOWorker()
   self.data = None
   def d(worker):
     self.data = worker.peek_receive_buf()
   i.set_receive_handler(d)
   i._push_receive_data("bar")
   self.assertEqual(self.data, "bar")
   # d does not consume the data
   i._push_receive_data("hepp")
   self.assertEqual(self.data, "barhepp")
Exemplo n.º 2
0
 def test_receive_consume(self):
   i = IOWorker()
   self.data = None
   def consume(worker):
     self.data = worker.peek_receive_buf()
     worker.consume_receive_buf(len(self.data))
   i.set_receive_handler(consume)
   i._push_receive_data("bar")
   self.assertEqual(self.data, "bar")
   # data has been consumed
   i._push_receive_data("hepp")
   self.assertEqual(self.data, "hepp")
Exemplo n.º 3
0
    def test_basic_receive(self):
        i = IOWorker()
        self.data = None

        def d(worker):
            self.data = worker.peek_receive_buf()

        i.set_receive_handler(d)
        i._push_receive_data("bar")
        self.assertEqual(self.data, "bar")
        # d does not consume the data
        i._push_receive_data("hepp")
        self.assertEqual(self.data, "barhepp")
Exemplo n.º 4
0
    def test_receive_consume(self):
        i = IOWorker()
        self.data = None

        def consume(worker):
            self.data = worker.peek_receive_buf()
            worker.consume_receive_buf(len(self.data))

        i.set_receive_handler(consume)
        i._push_receive_data("bar")
        self.assertEqual(self.data, "bar")
        # data has been consumed
        i._push_receive_data("hepp")
        self.assertEqual(self.data, "hepp")