[Python-checkins] distutils2: make sure test_pkutil works for 2.4, 2.5

tarek.ziade python-checkins at python.org
Mon Apr 5 23:09:20 CEST 2010


tarek.ziade pushed d59af2862093 to distutils2:

http://hg.python.org/distutils2/rev/d59af2862093
changeset:   110:d59af2862093
tag:         tip
user:        Tarek Ziade <tarek at ziade.org>
date:        Mon Apr 05 23:09:02 2010 +0200
summary:     make sure test_pkutil works for 2.4, 2.5
files:       src/distutils2/_backport/tests/test_pkgutil.py

diff --git a/src/distutils2/_backport/tests/test_pkgutil.py b/src/distutils2/_backport/tests/test_pkgutil.py
--- a/src/distutils2/_backport/tests/test_pkgutil.py
+++ b/src/distutils2/_backport/tests/test_pkgutil.py
@@ -4,7 +4,10 @@
 import sys
 import os
 import csv
-import hashlib
+try:
+    from hashlib import md5
+except ImportError:
+    from md5 import md5
 
 from test.test_support import run_unittest, TESTFN
 
@@ -29,7 +32,7 @@
             ]
 
         def get_hexdigest(file):
-            md5_hash = hashlib.md5()
+            md5_hash = md5()
             md5_hash.update(open(file).read())
             return md5_hash.hexdigest()
         def record_pieces(file):
@@ -57,8 +60,8 @@
             record_reader = csv.reader(open(record_file, 'rb'))
             record_data = []
             for row in record_reader:
-                path, md5, size = row[:] + [ None for i in xrange(len(row), 3) ]
-                record_data.append([path, (md5, size,)])
+                path, md5_, size = row[:] + [ None for i in xrange(len(row), 3) ]
+                record_data.append([path, (md5_, size,)])
             self.records[distinfo_dir] = dict(record_data)
 
     def tearDown(self):
@@ -93,10 +96,10 @@
         from distutils2._backport.pkgutil import Distribution
         for distinfo_dir in self.distinfo_dirs:
             dist = Distribution(distinfo_dir)
-            for path, md5, size in dist.get_installed_files():
+            for path, md5_, size in dist.get_installed_files():
                 record_data = self.records[dist.path]
                 self.assertTrue(path in record_data.keys())
-                self.assertEqual(md5, record_data[path][0])
+                self.assertEqual(md5_, record_data[path][0])
                 self.assertEqual(size, record_data[path][1])
 
     def test_uses(self):

--
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list