diff options
Diffstat (limited to 'Lib/test/test_bufio.py')
-rw-r--r-- | Lib/test/test_bufio.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Lib/test/test_bufio.py b/Lib/test/test_bufio.py index e65951d..7d617d3 100644 --- a/Lib/test/test_bufio.py +++ b/Lib/test/test_bufio.py @@ -1,9 +1,12 @@ import unittest from test import support -# Simple test to ensure that optimizations in fileobject.c deliver -# the expected results. For best testing, run this under a debug-build -# Python too (to exercise asserts in the C code). +import io # C implementation. +import _pyio as pyio # Python implementation. + +# Simple test to ensure that optimizations in the IO library deliver the +# expected results. For best testing, run this under a debug-build Python too +# (to exercise asserts in the C code). lengths = list(range(1, 257)) + [512, 1000, 1024, 2048, 4096, 8192, 10000, 16384, 32768, 65536, 1000000] @@ -18,7 +21,7 @@ class BufferSizeTest(unittest.TestCase): # Since C doesn't guarantee we can write/read arbitrary bytes in text # files, use binary mode. - f = open(support.TESTFN, "wb") + f = self.open(support.TESTFN, "wb") try: # write once with \n and once without f.write(s) @@ -58,8 +61,16 @@ class BufferSizeTest(unittest.TestCase): def test_nullpat(self): self.drive_one(bytes(1000)) + +class CBufferSizeTest(BufferSizeTest): + open = io.open + +class PyBufferSizeTest(BufferSizeTest): + open = staticmethod(pyio.open) + + def test_main(): - support.run_unittest(BufferSizeTest) + support.run_unittest(CBufferSizeTest, PyBufferSizeTest) if __name__ == "__main__": test_main() |