Back to index

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

List of all members.

Public Member Functions

def testCreateConnectionBase
def testCreateConnectionClose
def clientSetUp
def clientTearDown
def setUp
def tearDown
def serverExplicitReady
def clientRun

Public Attributes

 cli
 serv
 port
 setUp
 tearDown
 server_ready
 client_ready
 done
 queue
 client_thread

Private Member Functions

def _testSocketClass
def _testCreateConnectionBase
def _testCreateConnectionClose

Detailed Description

Definition at line 1929 of file test_socket.py.


Member Function Documentation

Definition at line 1951 of file test_socket.py.

01951 
01952     def _testCreateConnectionBase(self):
01953         address = self.serv.getsockname()
01954         with socket.create_connection(address) as sock:
01955             self.assertFalse(sock._closed)
01956             sock.sendall(b'foo')
01957             self.assertEqual(sock.recv(1024), b'foo')
01958         self.assertTrue(sock._closed)

Here is the call graph for this function:

Definition at line 1965 of file test_socket.py.

01965 
01966     def _testCreateConnectionClose(self):
01967         address = self.serv.getsockname()
01968         with socket.create_connection(address) as sock:
01969             sock.close()
01970         self.assertTrue(sock._closed)
01971         self.assertRaises(socket.error, sock.sendall, b'foo')
01972 
01973 
01974 @unittest.skipUnless(hasattr(socket, "SOCK_CLOEXEC"),
01975                      "SOCK_CLOEXEC not defined")
@unittest.skipUnless(fcntl, "module fcntl not available")

Here is the call graph for this function:

Definition at line 1931 of file test_socket.py.

01931 
01932     def _testSocketClass(self):
01933         # base test
01934         with socket.socket() as sock:
01935             self.assertFalse(sock._closed)
01936         self.assertTrue(sock._closed)
01937         # close inside with block
01938         with socket.socket() as sock:
01939             sock.close()
01940         self.assertTrue(sock._closed)
01941         # exception inside with block
01942         with socket.socket() as sock:
01943             self.assertRaises(socket.error, sock.sendall, b'foo')
01944         self.assertTrue(sock._closed)

Here is the call graph for this function:

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 1945 of file test_socket.py.

01945 
01946     def testCreateConnectionBase(self):
01947         conn, addr = self.serv.accept()
01948         self.addCleanup(conn.close)
01949         data = conn.recv(1024)
01950         conn.sendall(data)

Here is the call graph for this function:

Definition at line 1959 of file test_socket.py.

01959 
01960     def testCreateConnectionClose(self):
01961         conn, addr = self.serv.accept()
01962         self.addCleanup(conn.close)
01963         data = conn.recv(1024)
01964         conn.sendall(data)

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 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 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: