Back to index

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

List of all members.

Public Member Functions

def __init__
def clientSetUp
def clientTearDown
def setUp
def tearDown
def serverExplicitReady
def clientRun

Public Attributes

 source_port
 cli
 serv
 port
 setUp
 tearDown
 server_ready
 client_ready
 done
 queue
 client_thread

Static Public Attributes

 testFamily = _justAccept
 testSourceAddress = _justAccept
 testTimeoutDefault = _justAccept
 testTimeoutNone = _justAccept
 testTimeoutValueNamed = _justAccept
 testTimeoutValueNonamed = _justAccept

Private Member Functions

def _justAccept
def _testFamily
def _testSourceAddress
def _testTimeoutDefault
def _testTimeoutNone
def _testTimeoutValueNamed
def _testTimeoutValueNonamed

Detailed Description

Definition at line 1568 of file test_socket.py.


Constructor & Destructor Documentation

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

Definition at line 1570 of file test_socket.py.

01570 
01571     def __init__(self, methodName='runTest'):
01572         SocketTCPTest.__init__(self, methodName=methodName)
01573         ThreadableTest.__init__(self)

Here is the caller graph for this function:


Member Function Documentation

Definition at line 1582 of file test_socket.py.

01582 
01583     def _justAccept(self):
01584         conn, addr = self.serv.accept()
01585         conn.close()

Definition at line 1587 of file test_socket.py.

01587 
01588     def _testFamily(self):
01589         self.cli = socket.create_connection((HOST, self.port), timeout=30)
01590         self.addCleanup(self.cli.close)
01591         self.assertEqual(self.cli.family, 2)

Here is the call graph for this function:

Definition at line 1593 of file test_socket.py.

01593 
01594     def _testSourceAddress(self):
01595         self.cli = socket.create_connection((HOST, self.port), timeout=30,
01596                 source_address=('', self.source_port))
01597         self.addCleanup(self.cli.close)
01598         self.assertEqual(self.cli.getsockname()[1], self.source_port)
01599         # The port number being used is sufficient to show that the bind()
01600         # call happened.

Here is the call graph for this function:

Definition at line 1602 of file test_socket.py.

01602 
01603     def _testTimeoutDefault(self):
01604         # passing no explicit timeout uses socket's global default
01605         self.assertTrue(socket.getdefaulttimeout() is None)
01606         socket.setdefaulttimeout(42)
01607         try:
01608             self.cli = socket.create_connection((HOST, self.port))
01609             self.addCleanup(self.cli.close)
01610         finally:
01611             socket.setdefaulttimeout(None)
01612         self.assertEqual(self.cli.gettimeout(), 42)

Here is the call graph for this function:

Definition at line 1614 of file test_socket.py.

01614 
01615     def _testTimeoutNone(self):
01616         # None timeout means the same as sock.settimeout(None)
01617         self.assertTrue(socket.getdefaulttimeout() is None)
01618         socket.setdefaulttimeout(30)
01619         try:
01620             self.cli = socket.create_connection((HOST, self.port), timeout=None)
01621             self.addCleanup(self.cli.close)
01622         finally:
01623             socket.setdefaulttimeout(None)
01624         self.assertEqual(self.cli.gettimeout(), None)

Here is the call graph for this function:

Definition at line 1626 of file test_socket.py.

01626 
01627     def _testTimeoutValueNamed(self):
01628         self.cli = socket.create_connection((HOST, self.port), timeout=30)
01629         self.assertEqual(self.cli.gettimeout(), 30)

Here is the call graph for this function:

Definition at line 1631 of file test_socket.py.

01631 
01632     def _testTimeoutValueNonamed(self):
01633         self.cli = socket.create_connection((HOST, self.port), 30)
01634         self.addCleanup(self.cli.close)
01635         self.assertEqual(self.cli.gettimeout(), 30)
01636 
@unittest.skipUnless(thread, 'Threading required for this test.')

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.

Definition at line 1574 of file test_socket.py.

01574 
01575     def clientSetUp(self):
01576         self.source_port = support.find_unused_port()

Reimplemented from test.test_socket.ThreadableTest.

Definition at line 1577 of file test_socket.py.

01577 
01578     def clientTearDown(self):
01579         self.cli.close()
01580         self.cli = None
01581         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:


Member Data Documentation

Definition at line 1579 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 1575 of file test_socket.py.

Definition at line 121 of file test_socket.py.

Definition at line 1586 of file test_socket.py.

Definition at line 1592 of file test_socket.py.

Definition at line 1601 of file test_socket.py.

Definition at line 1613 of file test_socket.py.

Definition at line 1625 of file test_socket.py.

Definition at line 1630 of file test_socket.py.


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