[pypy-svn] r59618 - in pypy/trunk/pypy/module/bz2: . test
fijal at codespeak.net
fijal at codespeak.net
Sat Nov 1 13:17:45 CET 2008
Author: fijal
Date: Sat Nov 1 13:17:44 2008
New Revision: 59618
Added:
pypy/trunk/pypy/module/bz2/test/data.bz2 (contents, props changed)
Modified:
pypy/trunk/pypy/module/bz2/interp_bz2.py
pypy/trunk/pypy/module/bz2/test/test_bz2_compdecomp.py
Log:
Showcase failing assertion and a test that triggers it.
Modified: pypy/trunk/pypy/module/bz2/interp_bz2.py
==============================================================================
--- pypy/trunk/pypy/module/bz2/interp_bz2.py (original)
+++ pypy/trunk/pypy/module/bz2/interp_bz2.py Sat Nov 1 13:17:44 2008
@@ -648,9 +648,9 @@
break
elif rffi.getintfield(self.bzs, 'c_avail_out') == 0:
total_out = _bzs_total_out(self.bzs)
+ assert out_bufsize >= total_out
data = "".join([out_buf[i] for i in range(total_out)])
temp.append(data)
-
lltype.free(out_buf, flavor='raw')
out_bufsize = _new_buffer_size(out_bufsize)
out_buf = lltype.malloc(rffi.CCHARP.TO, out_bufsize, flavor='raw')
Added: pypy/trunk/pypy/module/bz2/test/data.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 Sat Nov 1 13:17:44 2008
@@ -1,6 +1,6 @@
from pypy.conftest import gettestobjspace
from pypy.module.bz2.test.support import CheckAllocation
-import os
+import os, py
HUGE_OK = False
@@ -25,6 +25,7 @@
mod.TEXT = 'root:x:0:0:root:/root:/bin/bash\nbin:x:1:1:bin:/bin:\ndaemon:x:2:2:daemon:/sbin:\nadm:x:3:4:adm:/var/adm:\nlp:x:4:7:lp:/var/spool/lpd:\nsync:x:5:0:sync:/sbin:/bin/sync\nshutdown:x:6:0:shutdown:/sbin:/sbin/shutdown\nhalt:x:7:0:halt:/sbin:/sbin/halt\nmail:x:8:12:mail:/var/spool/mail:\nnews:x:9:13:news:/var/spool/news:\nuucp:x:10:14:uucp:/var/spool/uucp:\noperator:x:11:0:operator:/root:\ngames:x:12:100:games:/usr/games:\ngopher:x:13:30:gopher:/usr/lib/gopher-data:\nftp:x:14:50:FTP User:/var/ftp:/bin/bash\nnobody:x:65534:65534:Nobody:/home:\npostfix:x:100:101:postfix:/var/spool/postfix:\nniemeyer:x:500:500::/home/niemeyer:/bin/bash\npostgres:x:101:102:PostgreSQL Server:/var/lib/pgsql:/bin/bash\nmysql:x:102:103:MySQL server:/var/lib/mysql:/bin/bash\nwww:x:103:104::/var/www:/bin/false\n'
mod.DATA = DATA
+ mod.BUGGY_DATA = py.magic.autopath().dirpath().join('data.bz2').read()
mod.decompress = decompress
class AppTestBZ2Compressor(CheckAllocation):
@@ -93,6 +94,7 @@
cls.space = space
cls.w_TEXT = space.wrap(TEXT)
cls.w_DATA = space.wrap(DATA)
+ cls.w_BUGGY_DATA = space.wrap(BUGGY_DATA)
def test_creation(self):
from bz2 import BZ2Decompressor
@@ -153,6 +155,14 @@
decompressed_data = bz2d.decompress(buffer(self.DATA))
assert decompressed_data == self.TEXT
+ def test_subsequent_read(self):
+ skip("Buggy")
+ from bz2 import BZ2Decompressor
+ bz2d = BZ2Decompressor()
+ decompressed_data = bz2d.decompress(self.BUGGY_DATA)
+ assert decompressed_data == ''
+ raises(IOError, bz2d.decompress, self.BUGGY_DATA)
+
class AppTestBZ2ModuleFunctions(CheckAllocation):
def setup_class(cls):
space = gettestobjspace(usemodules=('bz2',))
More information about the Pypy-commit
mailing list