[pypy-svn] r74974 - pypy/trunk/pypy/module/bz2/test

arigo at codespeak.net arigo at codespeak.net
Mon May 31 16:04:31 CEST 2010


Author: arigo
Date: Mon May 31 16:04:30 2010
New Revision: 74974

Added:
   pypy/trunk/pypy/module/bz2/test/largetest.bz2   (contents, props changed)
   pypy/trunk/pypy/module/bz2/test/test_large.py
Modified:
   pypy/trunk/pypy/module/bz2/test/test_bz2_compdecomp.py
Log:
issue541 in-progress

Add the test file, and found out that the multiple buffers
code in interp_bz2 is rather broken anyway, as shown by
random crashes when making the buffer size small.


Added: pypy/trunk/pypy/module/bz2/test/largetest.bz2
==============================================================================
Binary file. No diff available.

Modified: pypy/trunk/pypy/module/bz2/test/test_bz2_compdecomp.py
==============================================================================
--- pypy/trunk/pypy/module/bz2/test/test_bz2_compdecomp.py	(original)
+++ pypy/trunk/pypy/module/bz2/test/test_bz2_compdecomp.py	Mon May 31 16:04:30 2010
@@ -1,5 +1,6 @@
 from pypy.conftest import gettestobjspace
 from pypy.module.bz2.test.support import CheckAllocation
+from pypy.module.bz2 import interp_bz2
 import os, py
 
 HUGE_OK = False
@@ -27,6 +28,13 @@
     mod.DATA = DATA
     mod.BUGGY_DATA = py.path.local(__file__).dirpath().join('data.bz2').read()
     mod.decompress = decompress
+    #
+    # For tests, patch the value of SMALLCHUNK
+    mod.OLD_SMALLCHUNK = interp_bz2.SMALLCHUNK
+    interp_bz2.SMALLCHUNK = 32
+
+def teardown_module(mod):
+    interp_bz2.SMALLCHUNK = mod.OLD_SMALLCHUNK
 
 class AppTestBZ2Compressor(CheckAllocation):
     def setup_class(cls):

Added: pypy/trunk/pypy/module/bz2/test/test_large.py
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/module/bz2/test/test_large.py	Mon May 31 16:04:30 2010
@@ -0,0 +1,14 @@
+import py
+from pypy.conftest import gettestobjspace
+
+
+class AppTestBZ2File:
+    def setup_class(cls):
+        cls.space = gettestobjspace(usemodules=('bz2',))
+        largetest_bz2 = py.path.local(__file__).dirpath().join("largetest.bz2")
+        cls.w_compressed_data = cls.space.wrap(largetest_bz2.read())
+
+    def test_decompress(self):
+        from bz2 import decompress
+        result = decompress(self.compressed_data)
+        assert len(result) == 901179



More information about the Pypy-commit mailing list