def test_epsv(self):
# test wrong proto
try:
self.client.sendcmd('epsv ' + self.other_proto)
except ftplib.error_perm as err:
self.assertEqual(str(err)[0:3], "522")
else:
self.fail("Exception not raised")
# proto > 2
self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'epsv 3')
# test connection
for cmd in ('EPSV', 'EPSV ' + self.proto):
host, port = ftplib.parse229(self.client.sendcmd(cmd),
self.client.sock.getpeername())
with contextlib.closing(
socket.socket(self.client.af, socket.SOCK_STREAM)) as s:
s.settimeout(TIMEOUT)
s.connect((host, port))
self.client.sendcmd('abor')
评论列表
文章目录