Ejemplo n.º 1
0
 def test_write(self):
     msg = b'hello'
     t = SocketTransport(loop, self.ssock, self.read, self.close)
     t.write(msg)
     loop.start(pyev.EVRUN_NOWAIT)
     rmsg = self.csock.recv(len(msg))
     self.assertEqual(rmsg, msg)
Ejemplo n.º 2
0
 def test_write(self):
     msg = b"hello"
     t = SocketTransport(loop, self.ssock, self.read, self.close)
     t.write(msg)
     loop.start(pyev.EVRUN_NOWAIT)
     rmsg = self.csock.recv(len(msg))
     self.assertEqual(rmsg, msg)
Ejemplo n.º 3
0
 def test_buffered_write(self):
     t = SocketTransport(loop, self.ssock, self.read, self.close)
     count = 0
     msg = b'hello'
     while (t.write != t.buffered_write):
         count += 1
         t.write(msg)
     t.write(msg)
     self.csock.recv(count * len(msg))
     loop.start(pyev.EVRUN_NOWAIT)
     self.assertTrue(t.write == t.unbuffered_write)
Ejemplo n.º 4
0
 def test_buffered_write(self):
     t = SocketTransport(loop, self.ssock, self.read, self.close)
     count = 0
     msg = b"hello"
     while t.write != t.buffered_write:
         count += 1
         t.write(msg)
     t.write(msg)
     self.csock.recv(count * len(msg))
     loop.start(pyev.EVRUN_NOWAIT)
     self.assertTrue(t.write == t.unbuffered_write)
Ejemplo n.º 5
0
 def test_stop(self):
     self.server.start()
     csock = self.c_sock()
     self.c_connect(csock)
     loop.start(pyev.EVRUN_ONCE)
     self.assertTrue(self.c_isconnected(csock))
     self.server.stop()
     loop.start(pyev.EVRUN_ONCE)
     self.assertTrue(self.c_isconnected(csock))
     csock.close()
     csock = None
     loop.start(pyev.EVRUN_NOWAIT)
     csock = self.c_sock()
     self.c_connect(csock)
     self.assertTrue(self.factory.builds == 1)
Ejemplo n.º 6
0
 def test_stop(self):
     self.server.start()
     csock = self.c_sock()
     self.c_connect(csock)
     loop.start(pyev.EVRUN_ONCE)
     self.assertTrue(self.c_isconnected(csock))
     self.server.stop()
     loop.start(pyev.EVRUN_ONCE)
     self.assertTrue(self.c_isconnected(csock))
     csock.close()
     csock = None
     loop.start(pyev.EVRUN_NOWAIT)
     csock = self.c_sock()
     self.c_connect(csock)
     self.assertTrue(self.factory.builds == 1)
Ejemplo n.º 7
0
 def test_error(self):
     t = SocketTransport(loop, self.ssock, self.read, self.close)
     self.csock.close()
     t.write(b'hello')
     loop.start(pyev.EVRUN_NOWAIT)
     self.assertTrue(self.reason is not None)
Ejemplo n.º 8
0
 def test_read(self):
     t = SocketTransport(loop, self.ssock, self.read, self.close)
     t.start()
     self.csock.send(b'hello')
     loop.start(pyev.EVRUN_NOWAIT)
     self.assertEqual(self.data, b'hello')
Ejemplo n.º 9
0
 def test_start(self):
     self.server.start()
     csock = self.c_sock()
     self.c_connect(csock)
     loop.start(pyev.EVRUN_ONCE)
     self.assertTrue(self.c_isconnected(csock))
Ejemplo n.º 10
0
 def test_start(self):
     self.server.start()
     csock = self.c_sock()
     self.c_connect(csock)
     loop.start(pyev.EVRUN_ONCE)
     self.assertTrue(self.c_isconnected(csock))
Ejemplo n.º 11
0
 def test_error(self):
     t = SocketTransport(loop, self.ssock, self.read, self.close)
     self.csock.close()
     t.write(b"hello")
     loop.start(pyev.EVRUN_NOWAIT)
     self.assertTrue(self.reason is not None)
Ejemplo n.º 12
0
 def test_read(self):
     t = SocketTransport(loop, self.ssock, self.read, self.close)
     t.start()
     self.csock.send(b"hello")
     loop.start(pyev.EVRUN_NOWAIT)
     self.assertEqual(self.data, b"hello")