Back to index

python3.2  3.2.2
Classes | Public Member Functions
test.test_socket.NetworkConnectionNoServer Class Reference

List of all members.

Classes

class  MockSocket

Public Member Functions

def mocked_socket_module
def test_connect
def test_create_connection
def test_create_connection_timeout

Detailed Description

Definition at line 1527 of file test_socket.py.


Member Function Documentation

Return a socket which times out on connect

Definition at line 1534 of file test_socket.py.

01534 
01535     def mocked_socket_module(self):
01536         """Return a socket which times out on connect"""
01537         old_socket = socket.socket
01538         socket.socket = self.MockSocket
01539         try:
01540             yield
01541         finally:
01542             socket.socket = old_socket

Here is the caller graph for this function:

Definition at line 1543 of file test_socket.py.

01543 
01544     def test_connect(self):
01545         port = support.find_unused_port()
01546         cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
01547         self.addCleanup(cli.close)
01548         with self.assertRaises(socket.error) as cm:
01549             cli.connect((HOST, port))
01550         self.assertEqual(cm.exception.errno, errno.ECONNREFUSED)

Here is the call graph for this function:

Definition at line 1551 of file test_socket.py.

01551 
01552     def test_create_connection(self):
01553         # Issue #9792: errors raised by create_connection() should have
01554         # a proper errno attribute.
01555         port = support.find_unused_port()
01556         with self.assertRaises(socket.error) as cm:
01557             socket.create_connection((HOST, port))
01558         self.assertEqual(cm.exception.errno, errno.ECONNREFUSED)

Here is the call graph for this function:

Definition at line 1559 of file test_socket.py.

01559 
01560     def test_create_connection_timeout(self):
01561         # Issue #9792: create_connection() should not recast timeout errors
01562         # as generic socket errors.
01563         with self.mocked_socket_module():
01564             with self.assertRaises(socket.timeout):
01565                 socket.create_connection((HOST, 1234))
01566 
01567 
@unittest.skipUnless(thread, 'Threading required for this test.')

Here is the call graph for this function:


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