Back to index

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

List of all members.

Public Member Functions

def try_one
def drive_one
def test_primepat
def test_nullpat

Static Public Attributes

 open = io.open

Detailed Description

Definition at line 65 of file test_bufio.py.


Member Function Documentation

def test.test_bufio.BufferSizeTest.drive_one (   self,
  pattern 
) [inherited]

Definition at line 42 of file test_bufio.py.

00042 
00043     def drive_one(self, pattern):
00044         for length in lengths:
00045             # Repeat string 'pattern' as often as needed to reach total length
00046             # 'length'.  Then call try_one with that string, a string one larger
00047             # than that, and a string one smaller than that.  Try this with all
00048             # small sizes and various powers of 2, so we exercise all likely
00049             # stdio buffer sizes, and "off by one" errors on both sides.
00050             q, r = divmod(length, len(pattern))
00051             teststring = pattern * q + pattern[:r]
00052             self.assertEqual(len(teststring), length)
00053             self.try_one(teststring)
00054             self.try_one(teststring + b"x")
00055             self.try_one(teststring[:-1])

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_bufio.BufferSizeTest.test_nullpat (   self) [inherited]

Definition at line 61 of file test_bufio.py.

00061 
00062     def test_nullpat(self):
00063         self.drive_one(bytes(1000))
00064 

Here is the call graph for this function:

Definition at line 56 of file test_bufio.py.

00056 
00057     def test_primepat(self):
00058         # A pattern with prime length, to avoid simple relationships with
00059         # stdio buffer sizes.
00060         self.drive_one(b"1234567890\00\01\02\03\04\05\06")

Here is the call graph for this function:

def test.test_bufio.BufferSizeTest.try_one (   self,
  s 
) [inherited]

Definition at line 15 of file test_bufio.py.

00015 
00016     def try_one(self, s):
00017         # Write s + "\n" + s to file, then open it and ensure that successive
00018         # .readline()s deliver what we wrote.
00019 
00020         # Ensure we can open TESTFN for writing.
00021         support.unlink(support.TESTFN)
00022 
00023         # Since C doesn't guarantee we can write/read arbitrary bytes in text
00024         # files, use binary mode.
00025         f = self.open(support.TESTFN, "wb")
00026         try:
00027             # write once with \n and once without
00028             f.write(s)
00029             f.write(b"\n")
00030             f.write(s)
00031             f.close()
00032             f = open(support.TESTFN, "rb")
00033             line = f.readline()
00034             self.assertEqual(line, s + b"\n")
00035             line = f.readline()
00036             self.assertEqual(line, s)
00037             line = f.readline()
00038             self.assertTrue(not line) # Must be at EOF
00039             f.close()
00040         finally:
00041             support.unlink(support.TESTFN)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 66 of file test_bufio.py.


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