Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def clientSetUp
def clientTearDown
def testReadAfterTimeout
def testSmallRead
def testFullRead
def testUnbufferedRead
def testReadline
def testCloseAfterMakefile
def testMakefileAfterMakefileClose
def testClosedAttr
def testAttributes
def testRealClose
def serverExplicitReady
def clientRun

Public Attributes

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

Static Public Attributes

string read_mode = 'r'
tuple read_msg = MSG.decode('utf8')
string write_mode = 'w'
tuple write_msg = MSG.decode('utf8')
string newline = ''
int bufsize = 1
string encoding = 'utf8'
string errors = 'strict'

Detailed Description

Tests for socket.makefile() in text mode (rather than binary)

Definition at line 1504 of file test_socket.py.


Member Function Documentation

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

Definition at line 1134 of file test_socket.py.

01134 
01135     def clientSetUp(self):
01136         SocketConnectedTest.clientSetUp(self)
01137         self.write_file = self.serv_conn.makefile(
01138             self.write_mode, self.bufsize,
01139             encoding = self.encoding,
01140             errors = self.errors,
01141             newline = self.newline)

Reimplemented from test.test_socket.SocketConnectedTest.

Definition at line 1142 of file test_socket.py.

01142 
01143     def clientTearDown(self):
01144         self.cli_finished.set()
01145         self.write_file.close()
01146         self.assertTrue(self.write_file.closed)
01147         self.write_file = None
01148         SocketConnectedTest.clientTearDown(self)

Here is the call graph for this function:

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:

Reimplemented from test.test_socket.SocketConnectedTest.

Definition at line 1117 of file test_socket.py.

01117 
01118     def setUp(self):
01119         self.evt1, self.evt2, self.serv_finished, self.cli_finished = [
01120             threading.Event() for i in range(4)]
01121         SocketConnectedTest.setUp(self)
01122         self.read_file = self.cli_conn.makefile(
01123             self.read_mode, self.bufsize,
01124             encoding = self.encoding,
01125             errors = self.errors,
01126             newline = self.newline)

Here is the caller graph for this function:

Reimplemented from test.test_socket.SocketConnectedTest.

Definition at line 1127 of file test_socket.py.

01127 
01128     def tearDown(self):
01129         self.serv_finished.set()
01130         self.read_file.close()
01131         self.assertTrue(self.read_file.closed)
01132         self.read_file = None
01133         SocketConnectedTest.tearDown(self)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1237 of file test_socket.py.

01237 
01238     def testAttributes(self):
01239         self.assertEqual(self.read_file.mode, self.read_mode)
01240         self.assertEqual(self.read_file.name, self.cli_conn.fileno())

Here is the call graph for this function:

Definition at line 1209 of file test_socket.py.

01209 
01210     def testCloseAfterMakefile(self):
01211         # The file returned by makefile should keep the socket open.
01212         self.cli_conn.close()
01213         # read until EOF
01214         msg = self.read_file.read()
01215         self.assertEqual(msg, self.read_msg)

Here is the call graph for this function:

Definition at line 1231 of file test_socket.py.

01231 
01232     def testClosedAttr(self):
01233         self.assertTrue(not self.read_file.closed)

Here is the call graph for this function:

Definition at line 1177 of file test_socket.py.

01177 
01178     def testFullRead(self):
01179         # read until EOF
01180         msg = self.read_file.read()
01181         self.assertEqual(msg, self.read_msg)

Here is the call graph for this function:

Definition at line 1220 of file test_socket.py.

01220 
01221     def testMakefileAfterMakefileClose(self):
01222         self.read_file.close()
01223         msg = self.cli_conn.recv(len(MSG))
01224         if isinstance(self.read_msg, str):
01225             msg = msg.decode()
01226         self.assertEqual(msg, self.read_msg)

Here is the call graph for this function:

Definition at line 1149 of file test_socket.py.

01149 
01150     def testReadAfterTimeout(self):
01151         # Issue #7322: A file object must disallow further reads
01152         # after a timeout has occurred.
01153         self.cli_conn.settimeout(1)
01154         self.read_file.read(3)
01155         # First read raises a timeout
01156         self.assertRaises(socket.timeout, self.read_file.read, 1)
01157         # Second read is disallowed
01158         with self.assertRaises(IOError) as ctx:
01159             self.read_file.read(1)
01160         self.assertIn("cannot read from timed out object", str(ctx.exception))

Here is the call graph for this function:

Definition at line 1200 of file test_socket.py.

01200 
01201     def testReadline(self):
01202         # Performing file readline test
01203         line = self.read_file.readline()
01204         self.assertEqual(line, self.read_msg)

Here is the call graph for this function:

Definition at line 1245 of file test_socket.py.

01245 
01246     def testRealClose(self):
01247         self.read_file.close()
01248         self.assertRaises(ValueError, self.read_file.fileno)
01249         self.cli_conn.close()
01250         self.assertRaises(socket.error, self.cli_conn.getsockname)

Here is the call graph for this function:

Definition at line 1166 of file test_socket.py.

01166 
01167     def testSmallRead(self):
01168         # Performing small file read test
01169         first_seg = self.read_file.read(len(self.read_msg)-3)
01170         second_seg = self.read_file.read(3)
01171         msg = first_seg + second_seg
01172         self.assertEqual(msg, self.read_msg)

Here is the call graph for this function:

Definition at line 1186 of file test_socket.py.

01186 
01187     def testUnbufferedRead(self):
01188         # Performing unbuffered file read test
01189         buf = type(self.read_msg)()
01190         while 1:
01191             char = self.read_file.read(1)
01192             if not char:
01193                 break
01194             buf += char
01195         self.assertEqual(buf, self.read_msg)

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

Definition at line 1105 of file test_socket.py.

Definition at line 1106 of file test_socket.py.

Reimplemented from test.test_socket.FileObjectClassTestCase.

Definition at line 1511 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.UnbufferedFileObjectClassTestCase.

Definition at line 1121 of file test_socket.py.

Reimplemented from test.test_socket.FileObjectClassTestCase.

Definition at line 1507 of file test_socket.py.

Reimplemented from test.test_socket.FileObjectClassTestCase.

Definition at line 1508 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.

Definition at line 1136 of file test_socket.py.

Reimplemented from test.test_socket.FileObjectClassTestCase.

Definition at line 1509 of file test_socket.py.

Reimplemented from test.test_socket.FileObjectClassTestCase.

Definition at line 1510 of file test_socket.py.


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