~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_tuned_gzip.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-05-29 15:57:16 UTC
  • mfrom: (3427.5.9 dep_warnings)
  • Revision ID: pqm@pqm.ubuntu.com-20080529155716-0w3kic8lioa63231
(jam) Enable Deprecation Warnings when running -Werror and when
        running selftest

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
25
25
import zlib
26
26
 
27
27
 
28
 
from bzrlib.tuned_gzip import *
 
28
from bzrlib import tuned_gzip
29
29
 
30
30
 
31
31
class FakeDecompress(object):
36
36
 
37
37
    def decompress(self, buf):
38
38
        """Return an empty string as though we are at eof."""
39
 
        self.unused_data += buf
 
39
        # note that the zlib module *overwrites* unused data 
 
40
        # on writes after EOF.
 
41
        self.unused_data = buf
40
42
        return ''
41
43
 
42
44
 
59
61
        decompress.decompress('0')
60
62
        self.assertEqual('0', decompress.unused_data)
61
63
        # decompressing again (when the short read is read)
62
 
        # will give us the full value in the unused_data
 
64
        # will give us the latest input in the unused_data
 
65
        # this is arguably a bug in zlib but ...
63
66
        decompress.decompress('1234567')
64
 
        self.assertEqual('01234567', decompress.unused_data)
 
67
        self.assertEqual('1234567', decompress.unused_data)
65
68
 
66
69
 
67
70
class TestGzip(TestCase):
71
74
        # read more bytes if there is less than 8 bytes (the 
72
75
        # gzip trailer) unread.
73
76
        stream = StringIO('\0\0\0\0\0\0\0\0')
74
 
        myfile = GzipFile(fileobj=stream)
 
77
        myfile = tuned_gzip.GzipFile(fileobj=stream)
75
78
        # disable the _new_member check, we are microtesting.
76
79
        myfile._new_member = False
77
80
        myfile.crc = zlib.crc32('')