Back to index

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

List of all members.

Public Member Functions

def __init__
def testRecv
def testOverFlowRecv
def testRecvFrom
def testOverFlowRecvFrom
def testSendAll
def testFromFd
def testDup
def testShutdown
def testDetach
def setUp
def tearDown
def clientSetUp
def clientTearDown
def serverExplicitReady
def clientRun

Public Attributes

 cli_conn
 serv_conn
 setUp
 tearDown
 cli
 serv
 port
 server_ready
 client_ready
 done
 queue
 client_thread

Private Member Functions

def _testRecv
def _testOverFlowRecv
def _testRecvFrom
def _testOverFlowRecvFrom
def _testSendAll
def _testFromFd
def _testDup
def _testShutdown
def _testDetach

Detailed Description

Definition at line 786 of file test_socket.py.


Constructor & Destructor Documentation

def test.test_socket.BasicTCPTest.__init__ (   self,
  methodName = 'runTest' 
)

Reimplemented from test.test_socket.SocketConnectedTest.

Definition at line 788 of file test_socket.py.

00788 
00789     def __init__(self, methodName='runTest'):
00790         SocketConnectedTest.__init__(self, methodName=methodName)

Here is the caller graph for this function:


Member Function Documentation

Definition at line 891 of file test_socket.py.

00891 
00892     def _testDetach(self):
00893         self.serv_conn.send(MSG)
00894 
@unittest.skipUnless(thread, 'Threading required for this test.')
def test.test_socket.BasicTCPTest._testDup (   self) [private]

Definition at line 860 of file test_socket.py.

00860 
00861     def _testDup(self):
00862         self.serv_conn.send(MSG)

Definition at line 850 of file test_socket.py.

00850 
00851     def _testFromFd(self):
00852         self.serv_conn.send(MSG)

Definition at line 806 of file test_socket.py.

00806 
00807     def _testOverFlowRecv(self):
00808         self.serv_conn.send(MSG)

Definition at line 824 of file test_socket.py.

00824 
00825     def _testOverFlowRecvFrom(self):
00826         self.serv_conn.send(MSG)

def test.test_socket.BasicTCPTest._testRecv (   self) [private]

Definition at line 796 of file test_socket.py.

00796 
00797     def _testRecv(self):
00798         self.serv_conn.send(MSG)

Definition at line 814 of file test_socket.py.

00814 
00815     def _testRecvFrom(self):
00816         self.serv_conn.send(MSG)

Definition at line 837 of file test_socket.py.

00837 
00838     def _testSendAll(self):
00839         big_chunk = b'f' * 2048
00840         self.serv_conn.sendall(big_chunk)

Definition at line 872 of file test_socket.py.

00872 
00873     def _testShutdown(self):
00874         self.serv_conn.send(MSG)
00875         self.serv_conn.shutdown(2)

def test.test_socket.ThreadableTest.clientRun (   self,
  test_func 
) [inherited]

Definition at line 157 of file test_socket.py.

00157 
00158     def clientRun(self, test_func):
00159         self.server_ready.wait()
00160         self.client_ready.set()
00161         self.clientSetUp()
00162         if not hasattr(test_func, '__call__'):
00163             raise TypeError("test_func must be a callable function")
00164         try:
00165             test_func()
00166         except BaseException as e:
00167             self.queue.put(e)
00168         finally:
00169             self.clientTearDown()

Here is the call graph for this function:

Reimplemented from test.test_socket.ThreadedTCPSocketTest.

Reimplemented in test.test_socket.FileObjectClassTestCase.

Definition at line 228 of file test_socket.py.

00228 
00229     def clientSetUp(self):
00230         ThreadedTCPSocketTest.clientSetUp(self)
00231         self.cli.connect((HOST, self.port))
00232         self.serv_conn = self.cli

Reimplemented from test.test_socket.ThreadedTCPSocketTest.

Reimplemented in test.test_socket.FileObjectClassTestCase.

Definition at line 233 of file test_socket.py.

00233 
00234     def clientTearDown(self):
00235         self.serv_conn.close()
00236         self.serv_conn = None
00237         ThreadedTCPSocketTest.clientTearDown(self)

This method allows the server to explicitly indicate that
it wants the client thread to proceed. This is useful if the
server is about to execute a blocking routine that is
dependent upon the client thread during its setup routine.

Definition at line 123 of file test_socket.py.

00123 
00124     def serverExplicitReady(self):
00125         """This method allows the server to explicitly indicate that
00126         it wants the client thread to proceed. This is useful if the
00127         server is about to execute a blocking routine that is
00128         dependent upon the client thread during its setup routine."""
00129         self.server_ready.set()

Here is the caller graph for this function:

def test.test_socket.SocketConnectedTest.setUp (   self) [inherited]

Reimplemented from test.test_socket.SocketTCPTest.

Reimplemented in test.test_socket.FileObjectClassTestCase.

Definition at line 215 of file test_socket.py.

00215 
00216     def setUp(self):
00217         ThreadedTCPSocketTest.setUp(self)
00218         # Indicate explicitly we're ready for the client thread to
00219         # proceed and then perform the blocking call to accept
00220         self.serverExplicitReady()
00221         conn, addr = self.serv.accept()
00222         self.cli_conn = conn

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from test.test_socket.SocketTCPTest.

Reimplemented in test.test_socket.FileObjectClassTestCase.

Definition at line 223 of file test_socket.py.

00223 
00224     def tearDown(self):
00225         self.cli_conn.close()
00226         self.cli_conn = None
00227         ThreadedTCPSocketTest.tearDown(self)

Here is the caller graph for this function:

Definition at line 876 of file test_socket.py.

00876 
00877     def testDetach(self):
00878         # Testing detach()
00879         fileno = self.cli_conn.fileno()
00880         f = self.cli_conn.detach()
00881         self.assertEqual(f, fileno)
00882         # cli_conn cannot be used anymore...
00883         self.assertRaises(socket.error, self.cli_conn.recv, 1024)
00884         self.cli_conn.close()
00885         # ...but we can create another socket using the (still open)
00886         # file descriptor
00887         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=f)
00888         self.addCleanup(sock.close)
00889         msg = sock.recv(1024)
00890         self.assertEqual(msg, MSG)

Here is the call graph for this function:

Definition at line 853 of file test_socket.py.

00853 
00854     def testDup(self):
00855         # Testing dup()
00856         sock = self.cli_conn.dup()
00857         self.addCleanup(sock.close)
00858         msg = sock.recv(1024)
00859         self.assertEqual(msg, MSG)

Here is the call graph for this function:

Definition at line 841 of file test_socket.py.

00841 
00842     def testFromFd(self):
00843         # Testing fromfd()
00844         fd = self.cli_conn.fileno()
00845         sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM)
00846         self.addCleanup(sock.close)
00847         self.assertIsInstance(sock, socket.socket)
00848         msg = sock.recv(1024)
00849         self.assertEqual(msg, MSG)

Here is the call graph for this function:

Definition at line 799 of file test_socket.py.

00799 
00800     def testOverFlowRecv(self):
00801         # Testing receive in chunks over TCP
00802         seg1 = self.cli_conn.recv(len(MSG) - 3)
00803         seg2 = self.cli_conn.recv(1024)
00804         msg = seg1 + seg2
00805         self.assertEqual(msg, MSG)

Here is the call graph for this function:

Definition at line 817 of file test_socket.py.

00817 
00818     def testOverFlowRecvFrom(self):
00819         # Testing recvfrom() in chunks over TCP
00820         seg1, addr = self.cli_conn.recvfrom(len(MSG)-3)
00821         seg2, addr = self.cli_conn.recvfrom(1024)
00822         msg = seg1 + seg2
00823         self.assertEqual(msg, MSG)

Here is the call graph for this function:

Definition at line 791 of file test_socket.py.

00791 
00792     def testRecv(self):
00793         # Testing large receive over TCP
00794         msg = self.cli_conn.recv(1024)
00795         self.assertEqual(msg, MSG)

Here is the call graph for this function:

Definition at line 809 of file test_socket.py.

00809 
00810     def testRecvFrom(self):
00811         # Testing large recvfrom() over TCP
00812         msg, addr = self.cli_conn.recvfrom(1024)
00813         self.assertEqual(msg, MSG)

Here is the call graph for this function:

Definition at line 827 of file test_socket.py.

00827 
00828     def testSendAll(self):
00829         # Testing sendall() with a 2048 byte string over TCP
00830         msg = b''
00831         while 1:
00832             read = self.cli_conn.recv(1024)
00833             if not read:
00834                 break
00835             msg += read
00836         self.assertEqual(msg, b'f' * 2048)

Here is the call graph for this function:

Definition at line 863 of file test_socket.py.

00863 
00864     def testShutdown(self):
00865         # Testing shutdown()
00866         msg = self.cli_conn.recv(1024)
00867         self.assertEqual(msg, MSG)
00868         # wait for _testShutdown to finish: on OS X, when the server
00869         # closes the connection the client also becomes disconnected,
00870         # and the client's shutdown call will fail. (Issue #4397.)
00871         self.done.wait()

Here is the call graph for this function:


Member Data Documentation

Definition at line 184 of file test_socket.py.

Definition at line 221 of file test_socket.py.

Definition at line 132 of file test_socket.py.

Definition at line 141 of file test_socket.py.

Definition at line 133 of file test_socket.py.

Reimplemented in test.test_socket.NonBlockingTCPTests.

Definition at line 61 of file test_socket.py.

Definition at line 134 of file test_socket.py.

Reimplemented in test.test_socket.NonBlockingTCPTests.

Definition at line 60 of file test_socket.py.

Definition at line 231 of file test_socket.py.

Definition at line 131 of file test_socket.py.

Definition at line 120 of file test_socket.py.

Definition at line 121 of file test_socket.py.


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