def test_basic_receive(self):
   i = IOWorker()
   self.data = None
   def d(worker):
     self.data = worker.peek()
   i.rx_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")
 def test_receive_consume(self):
   i = IOWorker()
   self.data = None
   def consume(worker):
     self.data = worker.peek()
     worker.consume_receive_buf(len(self.data))
   i.rx_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")