Back to index

python3.2  3.2.2
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions
test.test_socket.FileObjectInterruptedTestCase Class Reference

List of all members.

Classes

class  MockSocket

Public Member Functions

def test_default
def test_with_1k_buffer
def test_no_buffer

Private Member Functions

def _textiowrap_mock_socket
def _test_readline
def _test_read
def _test_readline_no_buffer

Static Private Member Functions

def _raise_eintr

Detailed Description

Test that the file object correctly handles EINTR internally.

Definition at line 1255 of file test_socket.py.


Member Function Documentation

Definition at line 1285 of file test_socket.py.

01285 
01286     def _raise_eintr():
01287         raise socket.error(errno.EINTR)

Here is the caller graph for this function:

def test.test_socket.FileObjectInterruptedTestCase._test_read (   self,
  size = -1,
  buffering = -1 
) [private]

Definition at line 1311 of file test_socket.py.

01311 
01312     def _test_read(self, size=-1, buffering=-1):
01313         mock_sock = self.MockSocket(recv_funcs=[
01314                 lambda : b"This is the first line\nAnd the sec",
01315                 self._raise_eintr,
01316                 lambda : b"ond line is here\n",
01317                 lambda : b"",
01318                 lambda : b"",  # XXX(gps): io library does an extra EOF read
01319             ])
01320         expecting = (b"This is the first line\n"
01321                      b"And the second line is here\n")
01322         fo = mock_sock._textiowrap_for_test(buffering=buffering)
01323         if buffering == 0:
01324             data = b''
01325         else:
01326             data = ''
01327             expecting = expecting.decode('utf8')
01328         while len(data) != len(expecting):
01329             part = fo.read(size)
01330             if not part:
01331                 break
01332             data += part
01333         self.assertEqual(data, expecting)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_socket.FileObjectInterruptedTestCase._test_readline (   self,
  size = -1,
  buffering = -1 
) [private]

Definition at line 1299 of file test_socket.py.

01299 
01300     def _test_readline(self, size=-1, buffering=-1):
01301         mock_sock = self.MockSocket(recv_funcs=[
01302                 lambda : b"This is the first line\nAnd the sec",
01303                 self._raise_eintr,
01304                 lambda : b"ond line is here\n",
01305                 lambda : b"",
01306                 lambda : b"",  # XXX(gps): io library does an extra EOF read
01307             ])
01308         fo = mock_sock._textiowrap_for_test(buffering=buffering)
01309         self.assertEqual(fo.readline(size), "This is the first line\n")
01310         self.assertEqual(fo.readline(size), "And the second line is here\n")

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1346 of file test_socket.py.

01346 
01347     def _test_readline_no_buffer(self, size=-1):
01348         mock_sock = self.MockSocket(recv_funcs=[
01349                 lambda : b"a",
01350                 lambda : b"\n",
01351                 lambda : b"B",
01352                 self._raise_eintr,
01353                 lambda : b"b",
01354                 lambda : b"",
01355             ])
01356         fo = mock_sock._textiowrap_for_test(buffering=0)
01357         self.assertEqual(fo.readline(size), b"a\n")
01358         self.assertEqual(fo.readline(size), b"Bb")

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_socket.FileObjectInterruptedTestCase._textiowrap_mock_socket (   self,
  mock,
  buffering = -1 
) [private]

Definition at line 1288 of file test_socket.py.

01288 
01289     def _textiowrap_mock_socket(self, mock, buffering=-1):
01290         raw = socket.SocketIO(mock, "r")
01291         if buffering < 0:
01292             buffering = io.DEFAULT_BUFFER_SIZE
01293         if buffering == 0:
01294             return raw
01295         buffer = io.BufferedReader(raw, buffering)
01296         text = io.TextIOWrapper(buffer, None, None)
01297         text.mode = "rb"
01298         return text

Definition at line 1334 of file test_socket.py.

01334 
01335     def test_default(self):
01336         self._test_readline()
01337         self._test_readline(size=100)
01338         self._test_read()
01339         self._test_read(size=100)

Here is the call graph for this function:

Definition at line 1359 of file test_socket.py.

01359 
01360     def test_no_buffer(self):
01361         self._test_readline_no_buffer()
01362         self._test_readline_no_buffer(size=4)
01363         self._test_read(buffering=0)
01364         self._test_read(size=100, buffering=0)
01365 

Here is the call graph for this function:

Definition at line 1340 of file test_socket.py.

01340 
01341     def test_with_1k_buffer(self):
01342         self._test_readline(buffering=1024)
01343         self._test_readline(size=100, buffering=1024)
01344         self._test_read(buffering=1024)
01345         self._test_read(size=100, buffering=1024)

Here is the call graph for this function:


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