Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_ftplib.TestTimeouts Class Reference
Inheritance diagram for test.test_ftplib.TestTimeouts:
Inheritance graph
[legend]
Collaboration diagram for test.test_ftplib.TestTimeouts:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown
def server
def testTimeoutDefault
def testTimeoutNone
def testTimeoutValue
def testTimeoutConnect
def testTimeoutDifferentOrder
def testTimeoutDirectAccess

Public Attributes

 evt
 sock
 port

Detailed Description

Definition at line 765 of file test_ftplib.py.


Member Function Documentation

def test.test_ftplib.TestTimeouts.server (   self,
  evt,
  serv 
)

Definition at line 782 of file test_ftplib.py.

00782 
00783     def server(self, evt, serv):
00784         # This method sets the evt 3 times:
00785         #  1) when the connection is ready to be accepted.
00786         #  2) when it is safe for the caller to close the connection
00787         #  3) when we have closed the socket
00788         serv.listen(5)
00789         # (1) Signal the caller that we are ready to accept the connection.
00790         evt.set()
00791         try:
00792             conn, addr = serv.accept()
00793         except socket.timeout:
00794             pass
00795         else:
00796             conn.send(b"1 Hola mundo\n")
00797             # (2) Signal the caller that it is safe to close the socket.
00798             evt.set()
00799             conn.close()
00800         finally:
00801             serv.close()
00802             # (3) Signal the caller that we are done.
00803             evt.set()

Definition at line 767 of file test_ftplib.py.

00767 
00768     def setUp(self):
00769         self.evt = threading.Event()
00770         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
00771         self.sock.settimeout(3)
00772         self.port = support.bind_port(self.sock)
00773         threading.Thread(target=self.server, args=(self.evt,self.sock)).start()
00774         # Wait for the server to be ready.
00775         self.evt.wait()
00776         self.evt.clear()
00777         ftplib.FTP.port = self.port

Here is the caller graph for this function:

Definition at line 778 of file test_ftplib.py.

00778 
00779     def tearDown(self):
00780         self.evt.wait()
00781         self.sock.close()

Here is the caller graph for this function:

Definition at line 835 of file test_ftplib.py.

00835 
00836     def testTimeoutConnect(self):
00837         ftp = ftplib.FTP()
00838         ftp.connect(HOST, timeout=30)
00839         self.assertEqual(ftp.sock.gettimeout(), 30)
00840         self.evt.wait()
00841         ftp.close()

Here is the call graph for this function:

Definition at line 804 of file test_ftplib.py.

00804 
00805     def testTimeoutDefault(self):
00806         # default -- use global socket timeout
00807         self.assertTrue(socket.getdefaulttimeout() is None)
00808         socket.setdefaulttimeout(30)
00809         try:
00810             ftp = ftplib.FTP("localhost")
00811         finally:
00812             socket.setdefaulttimeout(None)
00813         self.assertEqual(ftp.sock.gettimeout(), 30)
00814         self.evt.wait()
00815         ftp.close()

Here is the call graph for this function:

Definition at line 842 of file test_ftplib.py.

00842 
00843     def testTimeoutDifferentOrder(self):
00844         ftp = ftplib.FTP(timeout=30)
00845         ftp.connect(HOST)
00846         self.assertEqual(ftp.sock.gettimeout(), 30)
00847         self.evt.wait()
00848         ftp.close()

Here is the call graph for this function:

Definition at line 849 of file test_ftplib.py.

00849 
00850     def testTimeoutDirectAccess(self):
00851         ftp = ftplib.FTP()
00852         ftp.timeout = 30
00853         ftp.connect(HOST)
00854         self.assertEqual(ftp.sock.gettimeout(), 30)
00855         self.evt.wait()
00856         ftp.close()
00857 

Here is the call graph for this function:

Definition at line 816 of file test_ftplib.py.

00816 
00817     def testTimeoutNone(self):
00818         # no timeout -- do not use global socket timeout
00819         self.assertTrue(socket.getdefaulttimeout() is None)
00820         socket.setdefaulttimeout(30)
00821         try:
00822             ftp = ftplib.FTP("localhost", timeout=None)
00823         finally:
00824             socket.setdefaulttimeout(None)
00825         self.assertTrue(ftp.sock.gettimeout() is None)
00826         self.evt.wait()
00827         ftp.close()

Here is the call graph for this function:

Definition at line 828 of file test_ftplib.py.

00828 
00829     def testTimeoutValue(self):
00830         # a value
00831         ftp = ftplib.FTP(HOST, timeout=30)
00832         self.assertEqual(ftp.sock.gettimeout(), 30)
00833         self.evt.wait()
00834         ftp.close()

Here is the call graph for this function:


Member Data Documentation

Definition at line 768 of file test_ftplib.py.

Definition at line 771 of file test_ftplib.py.

Definition at line 769 of file test_ftplib.py.


The documentation for this class was generated from the following file: