aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2016-07-03 19:20:02 +0200
committerGuido Günther <agx@sigxcpu.org>2016-07-04 14:09:58 +0200
commit0129d1527d35f68ae0360ba7814875dd1274acbb (patch)
tree1d790ebd6770c9d6643dd663aeb03c402e50d705
parente5a3d5bb47a2ddd44c77f1e919527ff3c7932fef (diff)
test_import_dsc: move _hash_file ComponenTestBase
Git-Dch: Ignore
-rw-r--r--tests/component/__init__.py10
-rw-r--r--tests/component/deb/test_import_dsc.py12
2 files changed, 12 insertions, 10 deletions
diff --git a/tests/component/__init__.py b/tests/component/__init__.py
index b6ba796..8354747 100644
--- a/tests/component/__init__.py
+++ b/tests/component/__init__.py
@@ -20,6 +20,7 @@
Module for testing individual command line tools of the git-buildpackage suite
"""
+import hashlib
import os
import shutil
import tempfile
@@ -205,3 +206,12 @@ class ComponentTestBase(unittest.TestCase, GbpLogTester):
for (h, s) in rem:
n = repo.rev_parse(h)
ok_(n == s, "Head '%s' points to %s' instead of '%s'" % (h, n, s))
+
+ @staticmethod
+ def hash_file(filename):
+ h = hashlib.md5()
+ with open(filename, 'rb') as f:
+ buf = f.read()
+ h.update(buf)
+ return h.hexdigest()
+
diff --git a/tests/component/deb/test_import_dsc.py b/tests/component/deb/test_import_dsc.py
index 615ef97..549b5e3 100644
--- a/tests/component/deb/test_import_dsc.py
+++ b/tests/component/deb/test_import_dsc.py
@@ -33,14 +33,6 @@ from gbp.deb.dscfile import DscFile
class TestImportDsc(ComponentTestBase):
"""Test importing of debian source packages"""
- @staticmethod
- def _hash_file(filename):
- h = hashlib.md5()
- with open(filename, 'rb') as f:
- buf = f.read()
- h.update(buf)
- return h.hexdigest()
-
def test_debian_import(self):
"""Test that importing of debian native packages works"""
def _dsc(version):
@@ -128,9 +120,9 @@ class TestImportDsc(ComponentTestBase):
outdir = os.path.abspath('.')
for f, w, s, o in ptars:
eq_(repo.get_subject(w), 'pristine-tar data for %s' % f)
- old = self._hash_file(o)
+ old = self.hash_file(o)
p.checkout('hello-debhelper', '2.8', 'gzip', outdir, subtarball=s)
- new = self._hash_file(os.path.join(outdir, f))
+ new = self.hash_file(os.path.join(outdir, f))
eq_(old, new, "Checksum %s of regenerated tarball %s does not match original %s" %
(f, old, new))