Back to index

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

List of all members.

Public Member Functions

def __init__
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
 cli_conn
 serv_conn
 setUp
 tearDown
 cli
 serv
 port
 server_ready
 client_ready
 done
 queue
 client_thread

Static Public Attributes

int bufsize = 1
string encoding = 'utf8'
string errors = 'strict'
 newline = None
string read_mode = 'rb'
 read_msg = MSG
string write_mode = 'wb'
 write_msg = MSG

Private Member Functions

def _testReadAfterTimeout
def _testSmallRead
def _testFullRead
def _testUnbufferedRead
def _testReadline
def _testCloseAfterMakefile
def _testMakefileAfterMakefileClose
def _testClosedAttr
def _testAttributes
def _testRealClose

Detailed Description

Unit tests for the object returned by socket.makefile()

self.read_file is the io object returned by makefile() on
the client connection.  You can read from this file to
get output from the server.

self.write_file is the io object returned by makefile() on the
server connection.  You can write to this file to send output
to the client.

Definition at line 1092 of file test_socket.py.


Constructor & Destructor Documentation

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

Reimplemented from test.test_socket.SocketConnectedTest.

Definition at line 1114 of file test_socket.py.

01114 
01115     def __init__(self, methodName='runTest'):
01116         SocketConnectedTest.__init__(self, methodName=methodName)

Here is the caller graph for this function:


Member Function Documentation

Definition at line 1241 of file test_socket.py.

01241 
01242     def _testAttributes(self):
01243         self.assertEqual(self.write_file.mode, self.write_mode)
01244         self.assertEqual(self.write_file.name, self.serv_conn.fileno())

Here is the call graph for this function:

Definition at line 1216 of file test_socket.py.

01216 
01217     def _testCloseAfterMakefile(self):
01218         self.write_file.write(self.write_msg)
01219         self.write_file.flush()

Definition at line 1234 of file test_socket.py.

01234 
01235     def _testClosedAttr(self):
01236         self.assertTrue(not self.write_file.closed)

Here is the call graph for this function:

Definition at line 1182 of file test_socket.py.

01182 
01183     def _testFullRead(self):
01184         self.write_file.write(self.write_msg)
01185         self.write_file.close()

Definition at line 1227 of file test_socket.py.

01227 
01228     def _testMakefileAfterMakefileClose(self):
01229         self.write_file.write(self.write_msg)
01230         self.write_file.flush()

Definition at line 1161 of file test_socket.py.

01161 
01162     def _testReadAfterTimeout(self):
01163         self.write_file.write(self.write_msg[0:3])
01164         self.write_file.flush()
01165         self.serv_finished.wait()

Definition at line 1205 of file test_socket.py.

01205 
01206     def _testReadline(self):
01207         self.write_file.write(self.write_msg)
01208         self.write_file.flush()

Definition at line 1251 of file test_socket.py.

01251 
01252     def _testRealClose(self):
01253         pass
01254 

Definition at line 1173 of file test_socket.py.

01173 
01174     def _testSmallRead(self):
01175         self.write_file.write(self.write_msg)
01176         self.write_file.flush()

Definition at line 1196 of file test_socket.py.

01196 
01197     def _testUnbufferedRead(self):
01198         self.write_file.write(self.write_msg)
01199         self.write_file.flush()

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


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