~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to mozilla/python/mozbuild/mozbuild/test/test_util.py

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# This Source Code Form is subject to the terms of the Mozilla Public
 
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
 
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
 
4
 
 
5
import hashlib
 
6
import unittest
 
7
 
 
8
from StringIO import StringIO
 
9
from tempfile import NamedTemporaryFile
 
10
 
 
11
from mozbuild.util import hash_file
 
12
 
 
13
 
 
14
class TestHashing(unittest.TestCase):
 
15
    def test_hash_file_known_hash(self):
 
16
        """Ensure a known hash value is recreated."""
 
17
        data = 'The quick brown fox jumps over the lazy cog'
 
18
        expected = 'de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3'
 
19
 
 
20
        temp = NamedTemporaryFile()
 
21
        temp.write(data)
 
22
        temp.flush()
 
23
 
 
24
        actual = hash_file(temp.name)
 
25
 
 
26
        self.assertEqual(actual, expected)
 
27
 
 
28
    def test_hash_file_large(self):
 
29
        """Ensure that hash_file seems to work with a large file."""
 
30
        data = 'x' * 1048576
 
31
 
 
32
        hasher = hashlib.sha1()
 
33
        hasher.update(data)
 
34
        expected = hasher.hexdigest()
 
35
 
 
36
        temp = NamedTemporaryFile()
 
37
        temp.write(data)
 
38
        temp.flush()
 
39
 
 
40
        actual = hash_file(temp.name)
 
41
 
 
42
        self.assertEqual(actual, expected)
 
43