Back to index

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

List of all members.

Public Member Functions

def __init__
def write
def writable
def fileno
def readable
def seekable
def seek
def tell
def readinto
def truncate

Private Attributes

 _read_stack
 _write_stack
 _reads
 _extraneous_reads

Detailed Description

A RawIO implementation without read(), so as to exercise the default
RawIO.read() which calls readinto().

Definition at line 53 of file test_io.py.


Constructor & Destructor Documentation

def test.test_io.MockRawIOWithoutRead.__init__ (   self,
  read_stack = () 
)

Definition at line 57 of file test_io.py.

00057 
00058     def __init__(self, read_stack=()):
00059         self._read_stack = list(read_stack)
00060         self._write_stack = []
00061         self._reads = 0
00062         self._extraneous_reads = 0

Here is the caller graph for this function:


Member Function Documentation

Definition at line 70 of file test_io.py.

00070 
00071     def fileno(self):
00072         return 42

Here is the caller graph for this function:

Definition at line 73 of file test_io.py.

00073 
00074     def readable(self):
00075         return True

def test.test_io.MockRawIOWithoutRead.readinto (   self,
  buf 
)

Reimplemented in test.test_io.MisbehavedRawIO.

Definition at line 85 of file test_io.py.

00085 
00086     def readinto(self, buf):
00087         self._reads += 1
00088         max_len = len(buf)
00089         try:
00090             data = self._read_stack[0]
00091         except IndexError:
00092             self._extraneous_reads += 1
00093             return 0
00094         if data is None:
00095             del self._read_stack[0]
00096             return None
00097         n = len(data)
00098         if len(data) <= max_len:
00099             del self._read_stack[0]
00100             buf[:n] = data
00101             return n
00102         else:
00103             buf[:] = data[:max_len]
00104             self._read_stack[0] = data[max_len:]
00105             return max_len

def test.test_io.MockRawIOWithoutRead.seek (   self,
  pos,
  whence 
)

Reimplemented in test.test_io.MisbehavedRawIO.

Definition at line 79 of file test_io.py.

00079 
00080     def seek(self, pos, whence):
00081         return 0   # wrong but we gotta return something

Here is the caller graph for this function:

Definition at line 76 of file test_io.py.

00076 
00077     def seekable(self):
00078         return True

Reimplemented in test.test_io.MisbehavedRawIO.

Definition at line 82 of file test_io.py.

00082 
00083     def tell(self):
00084         return 0   # same comment as above

def test.test_io.MockRawIOWithoutRead.truncate (   self,
  pos = None 
)

Definition at line 106 of file test_io.py.

00106 
00107     def truncate(self, pos=None):
00108         return pos

Definition at line 67 of file test_io.py.

00067 
00068     def writable(self):
00069         return True

def test.test_io.MockRawIOWithoutRead.write (   self,
  b 
)

Reimplemented in test.test_io.MisbehavedRawIO.

Definition at line 63 of file test_io.py.

00063 
00064     def write(self, b):
00065         self._write_stack.append(bytes(b))
00066         return len(b)


Member Data Documentation

Definition at line 61 of file test_io.py.

Definition at line 58 of file test_io.py.

Definition at line 60 of file test_io.py.

Definition at line 59 of file test_io.py.


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