/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_tuned_gzip.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import gzip
21
21
from io import BytesIO
 
22
import zlib
22
23
 
23
24
from .. import (
24
25
    tuned_gzip,
31
32
    def assertToGzip(self, chunks):
32
33
        raw_bytes = b''.join(chunks)
33
34
        gzfromchunks = tuned_gzip.chunks_to_gzip(chunks)
34
 
        decoded = gzip.GzipFile(fileobj=BytesIO(b''.join(gzfromchunks))).read()
 
35
        gzfrombytes = tuned_gzip.bytes_to_gzip(raw_bytes)
 
36
        self.assertEqual(gzfrombytes, gzfromchunks)
 
37
        decoded = gzip.GzipFile(fileobj=BytesIO(gzfromchunks)).read()
35
38
        lraw, ldecoded = len(raw_bytes), len(decoded)
36
39
        self.assertEqual(lraw, ldecoded,
37
40
                         'Expecting data length %d, got %d' % (lraw, ldecoded))
44
47
        self.assertToGzip([b'some\n', b'strings\n', b'to\n', b'process\n'])
45
48
 
46
49
    def test_large_chunks(self):
47
 
        self.assertToGzip([b'a large string\n' * 1024])
48
 
        self.assertToGzip([b'a large string\n'] * 1024)
 
50
        self.assertToGzip([b'a large string\n'*1024])
 
51
        self.assertToGzip([b'a large string\n']*1024)
49
52
 
50
53
    def test_enormous_chunks(self):
51
 
        self.assertToGzip([b'a large string\n' * 1024 * 256])
52
 
        self.assertToGzip([b'a large string\n'] * 1024 * 256)
 
54
        self.assertToGzip([b'a large string\n'*1024*256])
 
55
        self.assertToGzip([b'a large string\n']*1024*256)