Exemple #1
0
 def test_basic_send(self):
   i = IOWorker()
   i.send("foo")
   self.assertTrue(i._ready_to_send)
   self.assertEqual(i.send_buf, "foo")
   i._consume_send_buf(3)
   self.assertFalse(i._ready_to_send)
 def test_basic_send(self):
     i = IOWorker()
     i.send(b"foo")
     self.assertTrue(i._ready_to_send)
     self.assertEqual(i.send_buf, b"foo")
     i._consume_send_buf(3)
     self.assertFalse(i._ready_to_send)
    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(b"bar")
        self.assertEqual(self.data, b"bar")
        # d does not consume the data
        i._push_receive_data(b"hepp")
        self.assertEqual(self.data, b"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(b"bar")
        self.assertEqual(self.data, b"bar")
        # data has been consumed
        i._push_receive_data(b"hepp")
        self.assertEqual(self.data, b"hepp")
Exemple #5
0
 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")
Exemple #6
0
 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")