Back to index

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

List of all members.

Public Member Functions

def __init__
def testSetBlocking
def testInitNonBlocking
def testInheritFlags
def testAccept
def testConnect
def testRecv
def clientSetUp
def clientTearDown
def setUp
def tearDown
def serverExplicitReady
def clientRun

Public Attributes

 serv
 port
 cli
 setUp
 tearDown
 server_ready
 client_ready
 done
 queue
 client_thread

Private Member Functions

def _testSetBlocking
def _testInitNonBlocking
def _testInheritFlags
def _testAccept
def _testConnect
def _testRecv

Detailed Description

Definition at line 979 of file test_socket.py.


Constructor & Destructor Documentation

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

Reimplemented from test.test_socket.ThreadedTCPSocketTest.

Definition at line 981 of file test_socket.py.

00981 
00982     def __init__(self, methodName='runTest'):
00983         ThreadedTCPSocketTest.__init__(self, methodName=methodName)

Here is the caller graph for this function:


Member Function Documentation

Definition at line 1055 of file test_socket.py.

01055 
01056     def _testAccept(self):
01057         time.sleep(0.1)
01058         self.cli.connect((HOST, self.port))

Definition at line 1064 of file test_socket.py.

01064 
01065     def _testConnect(self):
01066         self.cli.settimeout(10)
01067         self.cli.connect((HOST, self.port))

Definition at line 1033 of file test_socket.py.

01033 
01034     def _testInheritFlags(self):
01035         time.sleep(0.1)
01036         self.cli.connect((HOST, self.port))
01037         time.sleep(0.5)
01038         self.cli.send(MSG)

Definition at line 1019 of file test_socket.py.

01019 
01020         def _testInitNonBlocking(self):
01021             pass

Definition at line 1086 of file test_socket.py.

01086 
01087     def _testRecv(self):
01088         self.cli.connect((HOST, self.port))
01089         time.sleep(0.1)
01090         self.cli.send(MSG)
01091 
@unittest.skipUnless(thread, 'Threading required for this test.')

Definition at line 995 of file test_socket.py.

00995 
00996     def _testSetBlocking(self):
00997         pass

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.ThreadableTest.

Reimplemented in test.test_socket.FileObjectClassTestCase, and test.test_socket.SocketConnectedTest.

Definition at line 183 of file test_socket.py.

00183 
00184     def clientSetUp(self):
00185         self.cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

Reimplemented from test.test_socket.ThreadableTest.

Reimplemented in test.test_socket.FileObjectClassTestCase, and test.test_socket.SocketConnectedTest.

Definition at line 186 of file test_socket.py.

00186 
00187     def clientTearDown(self):
00188         self.cli.close()
00189         self.cli = None
00190         ThreadableTest.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.SocketTCPTest.setUp (   self) [inherited]

Reimplemented in test.test_socket.FileObjectClassTestCase, and test.test_socket.SocketConnectedTest.

Definition at line 59 of file test_socket.py.

00059 
00060     def setUp(self):
00061         self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
00062         self.port = support.bind_port(self.serv)
00063         self.serv.listen(1)

Here is the caller graph for this function:

def test.test_socket.SocketTCPTest.tearDown (   self) [inherited]

Reimplemented in test.test_socket.FileObjectClassTestCase, and test.test_socket.SocketConnectedTest.

Definition at line 64 of file test_socket.py.

00064 
00065     def tearDown(self):
00066         self.serv.close()
00067         self.serv = None

Here is the caller graph for this function:

Definition at line 1039 of file test_socket.py.

01039 
01040     def testAccept(self):
01041         # Testing non-blocking accept
01042         self.serv.setblocking(0)
01043         try:
01044             conn, addr = self.serv.accept()
01045         except socket.error:
01046             pass
01047         else:
01048             self.fail("Error trying to do non-blocking accept.")
01049         read, write, err = select.select([self.serv], [], [])
01050         if self.serv in read:
01051             conn, addr = self.serv.accept()
01052             conn.close()
01053         else:
01054             self.fail("Error trying to do accept after select.")

Here is the call graph for this function:

Definition at line 1059 of file test_socket.py.

01059 
01060     def testConnect(self):
01061         # Testing non-blocking connect
01062         conn, addr = self.serv.accept()
01063         conn.close()

Definition at line 1022 of file test_socket.py.

01022 
01023     def testInheritFlags(self):
01024         # Issue #7995: when calling accept() on a listening socket with a
01025         # timeout, the resulting socket should not be non-blocking.
01026         self.serv.settimeout(10)
01027         try:
01028             conn, addr = self.serv.accept()
01029             message = conn.recv(len(MSG))
01030         finally:
01031             conn.close()
01032             self.serv.settimeout(None)

Definition at line 999 of file test_socket.py.

00999 
01000         def testInitNonBlocking(self):
01001             v = linux_version()
01002             if v < (2, 6, 28):
01003                 self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
01004                               % ".".join(map(str, v)))
01005             # reinit server socket
01006             self.serv.close()
01007             self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM |
01008                                                       socket.SOCK_NONBLOCK)
01009             self.port = support.bind_port(self.serv)
01010             self.serv.listen(1)
01011             # actual testing
01012             start = time.time()
01013             try:
01014                 self.serv.accept()
01015             except socket.error:
01016                 pass
01017             end = time.time()
01018             self.assertTrue((end - start) < 1.0, "Error creating with non-blocking mode.")

Here is the call graph for this function:

Definition at line 1068 of file test_socket.py.

01068 
01069     def testRecv(self):
01070         # Testing non-blocking recv
01071         conn, addr = self.serv.accept()
01072         conn.setblocking(0)
01073         try:
01074             msg = conn.recv(len(MSG))
01075         except socket.error:
01076             pass
01077         else:
01078             self.fail("Error trying to do non-blocking recv.")
01079         read, write, err = select.select([conn], [], [])
01080         if conn in read:
01081             msg = conn.recv(len(MSG))
01082             conn.close()
01083             self.assertEqual(msg, MSG)
01084         else:
01085             self.fail("Error during select call to non-blocking socket.")

Here is the call graph for this function:

Definition at line 984 of file test_socket.py.

00984 
00985     def testSetBlocking(self):
00986         # Testing whether set blocking works
00987         self.serv.setblocking(0)
00988         start = time.time()
00989         try:
00990             self.serv.accept()
00991         except socket.error:
00992             pass
00993         end = time.time()
00994         self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.")

Here is the call graph for this function:


Member Data Documentation

Definition at line 184 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 from test.test_socket.SocketTCPTest.

Definition at line 1008 of file test_socket.py.

Definition at line 134 of file test_socket.py.

Reimplemented from test.test_socket.SocketTCPTest.

Definition at line 1006 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: