[Python-checkins] distutils2: Adding the test for Distribution.get_installed_files.

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


tarek.ziade pushed e7b63f7487a2 to distutils2:

http://hg.python.org/distutils2/rev/e7b63f7487a2
changeset:   101:e7b63f7487a2
user:        pumazi
date:        Wed Mar 31 15:10:02 2010 -0400
summary:     Adding the test for Distribution.get_installed_files.
files:       src/distutils2/_backport/pkgutil.py, src/distutils2/_backport/tests/test_pkgutil.py

diff --git a/src/distutils2/_backport/pkgutil.py b/src/distutils2/_backport/pkgutil.py
--- a/src/distutils2/_backport/pkgutil.py
+++ b/src/distutils2/_backport/pkgutil.py
@@ -7,6 +7,7 @@
 import sys
 import imp
 import os.path
+from csv import reader as csv_reader
 from types import ModuleType
 from distutils2.metadata import DistributionMetadata
 from distutils2.version import suggest_normalized_version
@@ -627,7 +628,11 @@
         :type local: boolean
         :returns: iterator of (path, md5, size)
         """
-        pass
+        RECORD = os.path.join(self.path, 'RECORD')
+        record_reader = csv_reader(open(RECORD, 'rb'), delimiter=',')
+        for row in record_reader:
+            value = row[:] + [ None for i in xrange(len(row), 3) ]
+            yield value
 
     def uses(self, path):
         """
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
@@ -66,9 +66,24 @@
             record_writer.writerow(record_pieces(
                 os.path.join(distinfo_location, file)))
         record_writer.writerow([record_file])
+        del record_writer
+        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,)])
+        record_data = dict(record_data)
 
-        # Test choxie's installed files
-        
+        # Test the distribution's installed files
+        from distutils2._backport.pkgutil import Distribution
+        dist = Distribution(distinfo_location)
+        for path, md5, size in dist.get_installed_files():
+            self.assertTrue(path in record_data.keys())
+            self.assertEqual(md5, record_data[path][0])
+            self.assertEqual(size, record_data[path][1])
+
+        # Clear the RECORD file
+        open(record_file, 'w').close()
 
 
 class TestPkgUtilFunctions(unittest2.TestCase):

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


More information about the Python-checkins mailing list