Commits

Anonymous committed e7b63f7

Adding the test for Distribution.get_installed_files.

Comments (0)

Files changed (2)

src/distutils2/_backport/pkgutil.py

 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
         :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):
         """

src/distutils2/_backport/tests/test_pkgutil.py

             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):