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)
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)
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)
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)
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)
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)
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')
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))
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)
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")