[pypy-svn] r31107 - pypy/dist/pypy/module/bz2/test

rhymes at codespeak.net rhymes at codespeak.net
Mon Aug 7 15:29:21 CEST 2006


Author: rhymes
Date: Mon Aug  7 15:29:18 2006
New Revision: 31107

Modified:
   pypy/dist/pypy/module/bz2/test/test_bz2.py
Log:
one more test for compress() function

Modified: pypy/dist/pypy/module/bz2/test/test_bz2.py
==============================================================================
--- pypy/dist/pypy/module/bz2/test/test_bz2.py	(original)
+++ pypy/dist/pypy/module/bz2/test/test_bz2.py	Mon Aug  7 15:29:18 2006
@@ -724,7 +724,8 @@
         bz2d = BZ2Decompressor()
         bz2d.decompress(DATA)
         raises(EOFError, bz2d.decompress, "foo")
-        
+
+
 def test_compress_function():
     def decompress(data):
         import popen2
@@ -749,6 +750,27 @@
     data = compress(TEXT)
     assert decompress(data) == TEXT
 
+def test_compress_function_huge_data():
+    def decompress(data):
+        import popen2
+        import bz2
+        pop = popen2.Popen3("bunzip2", capturestderr=1)
+        pop.tochild.write(data)
+        pop.tochild.close()
+        res = pop.fromchild.read()
+        pop.fromchild.close()
+        if pop.wait() != 0:
+            res = bz2.decompress(data)
+        return res
+
+    from bz2 import compress
+    
+    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'
+    HUGE_DATA = TEXT * 10000
+
+    data = compress(HUGE_DATA)
+    assert decompress(data) == HUGE_DATA
+
 # has_cmdline_bunzip2 = sys.platform not in ("win32", "os2emx", "riscos")
 # 
 # if has_cmdline_bunzip2:



More information about the Pypy-commit mailing list