~ubuntu-branches/ubuntu/utopic/dulwich/utopic-proposed

« back to all changes in this revision

Viewing changes to dulwich/tests/test_pack.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2014-01-29 00:30:26 UTC
  • mfrom: (1.5.4)
  • Revision ID: package-import@ubuntu.com-20140129003026-e483cc2gb1yfhj6d
Tags: 0.9.5-1
* Add upstream PGP signing key.
* Enable autopkgtest.
* New upstream release.
* Bump standards version to 3.9.5 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
 
23
23
from cStringIO import StringIO
 
24
from hashlib import sha1
24
25
import os
25
26
import shutil
26
27
import tempfile
27
28
import zlib
28
29
 
29
 
from dulwich._compat import (
30
 
    make_sha,
31
 
    )
32
30
from dulwich.errors import (
33
31
    ChecksumMismatch,
34
32
    )
250
248
 
251
249
    def test_compute_file_sha(self):
252
250
        f = StringIO('abcd1234wxyz')
253
 
        self.assertEqual(make_sha('abcd1234wxyz').hexdigest(),
 
251
        self.assertEqual(sha1('abcd1234wxyz').hexdigest(),
254
252
                         compute_file_sha(f).hexdigest())
255
 
        self.assertEqual(make_sha('abcd1234wxyz').hexdigest(),
 
253
        self.assertEqual(sha1('abcd1234wxyz').hexdigest(),
256
254
                         compute_file_sha(f, buffer_size=5).hexdigest())
257
 
        self.assertEqual(make_sha('abcd1234').hexdigest(),
 
255
        self.assertEqual(sha1('abcd1234').hexdigest(),
258
256
                         compute_file_sha(f, end_ofs=-4).hexdigest())
259
 
        self.assertEqual(make_sha('1234wxyz').hexdigest(),
 
257
        self.assertEqual(sha1('1234wxyz').hexdigest(),
260
258
                         compute_file_sha(f, start_ofs=4).hexdigest())
261
259
        self.assertEqual(
262
 
          make_sha('1234').hexdigest(),
 
260
          sha1('1234').hexdigest(),
263
261
          compute_file_sha(f, start_ofs=4, end_ofs=-4).hexdigest())
264
262
 
265
263
 
504
502
        f = StringIO()
505
503
        f.write('header')
506
504
        offset = f.tell()
507
 
        sha_a = make_sha('foo')
 
505
        sha_a = sha1('foo')
508
506
        sha_b = sha_a.copy()
509
507
        write_pack_object(f, Blob.type_num, 'blob', sha=sha_a)
510
508
        self.assertNotEqual(sha_a.digest(), sha_b.digest())