Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_read_until
def test_read_all
def test_read_some
def test_read_eager
def read_very_lazy
def test_read_lazy

Public Attributes

 old_select

Private Member Functions

def _read_eager

Detailed Description

Definition at line 142 of file test_telnetlib.py.


Member Function Documentation

def test.test_telnetlib.ReadTests._read_eager (   self,
  func_name 
) [private]
read_*_eager()
  Read all data available already queued or on the socket,
  without blocking.

Definition at line 192 of file test_telnetlib.py.

00192 
00193     def _read_eager(self, func_name):
00194         """
00195         read_*_eager()
00196           Read all data available already queued or on the socket,
00197           without blocking.
00198         """
00199         want = b'x' * 100
00200         telnet = test_telnet([want])
00201         func = getattr(telnet, func_name)
00202         telnet.sock.block = True
00203         self.assertEqual(b'', func())
00204         telnet.sock.block = False
00205         data = b''
00206         while True:
00207             try:
00208                 data += func()
00209             except EOFError:
00210                 break
00211         self.assertEqual(data, want)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 220 of file test_telnetlib.py.

00220 
00221     def read_very_lazy(self):
00222         want = b'x' * 100
00223         telnet = test_telnet([want])
00224         self.assertEqual(b'', telnet.read_very_lazy())
00225         while telnet.sock.reads:
00226             telnet.fill_rawq()
00227         data = telnet.read_very_lazy()
00228         self.assertEqual(want, data)
00229         self.assertRaises(EOFError, telnet.read_very_lazy)

Here is the call graph for this function:

Definition at line 143 of file test_telnetlib.py.

00143 
00144     def setUp(self):
00145         self.old_select = select.select
        select.select = new_select

Here is the caller graph for this function:

Definition at line 146 of file test_telnetlib.py.

00146 
00147     def tearDown(self):
00148         select.select = self.old_select

Here is the caller graph for this function:

read_all()
  Read all data until EOF; may block.

Definition at line 166 of file test_telnetlib.py.

00166 
00167     def test_read_all(self):
00168         """
00169         read_all()
00170           Read all data until EOF; may block.
00171         """
00172         reads = [b'x' * 500, b'y' * 500, b'z' * 500]
00173         expect = b''.join(reads)
00174         telnet = test_telnet(reads)
00175         data = telnet.read_all()
00176         self.assertEqual(data, expect)
00177         return

Here is the call graph for this function:

Definition at line 212 of file test_telnetlib.py.

00212 
00213     def test_read_eager(self):
00214         # read_eager and read_very_eager make the same gaurantees
00215         # (they behave differently but we only test the gaurantees)
00216         self._read_eager('read_eager')
00217         self._read_eager('read_very_eager')
00218         # NB -- we need to test the IAC block which is mentioned in the
00219         # docstring but not in the module docs

Here is the call graph for this function:

Definition at line 230 of file test_telnetlib.py.

00230 
00231     def test_read_lazy(self):
00232         want = b'x' * 100
00233         telnet = test_telnet([want])
00234         self.assertEqual(b'', telnet.read_lazy())
00235         data = b''
00236         while True:
00237             try:
00238                 read_data = telnet.read_lazy()
00239                 data += read_data
00240                 if not read_data:
00241                     telnet.fill_rawq()
00242             except EOFError:
00243                 break
00244             self.assertTrue(want.startswith(data))
00245         self.assertEqual(data, want)

Here is the call graph for this function:

read_some()
  Read at least one byte or EOF; may block.

Definition at line 178 of file test_telnetlib.py.

00178 
00179     def test_read_some(self):
00180         """
00181         read_some()
00182           Read at least one byte or EOF; may block.
00183         """
00184         # test 'at least one byte'
00185         telnet = test_telnet([b'x' * 500])
00186         data = telnet.read_some()
00187         self.assertTrue(len(data) >= 1)
00188         # test EOF
00189         telnet = test_telnet()
00190         data = telnet.read_some()
00191         self.assertEqual(b'', data)

Here is the call graph for this function:

read_until(expected, timeout=None)
test the blocking version of read_util

Definition at line 149 of file test_telnetlib.py.

00149 
00150     def test_read_until(self):
00151         """
00152         read_until(expected, timeout=None)
00153         test the blocking version of read_util
00154         """
00155         want = [b'xxxmatchyyy']
00156         telnet = test_telnet(want)
00157         data = telnet.read_until(b'match')
00158         self.assertEqual(data, b'xxxmatch', msg=(telnet.cookedq, telnet.rawq, telnet.sock.reads))
00159 
00160         reads = [b'x' * 50, b'match', b'y' * 50]
00161         expect = b''.join(reads[:-1])
00162         telnet = test_telnet(reads)
00163         data = telnet.read_until(b'match')
00164         self.assertEqual(data, expect)
00165 

Here is the call graph for this function:


Member Data Documentation

Definition at line 144 of file test_telnetlib.py.


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