[Python-checkins] distutils2: That completes the preliminary tests for pep376. Now it's time to go over it

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


tarek.ziade pushed aade6bc810a5 to distutils2:

http://hg.python.org/distutils2/rev/aade6bc810a5
changeset:   108:aade6bc810a5
user:        pumazi
date:        Thu Apr 01 22:54:16 2010 -0400
summary:     That completes the preliminary tests for pep376. Now it's time to go over it with a fine toothed comb.
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
@@ -786,4 +786,6 @@
                      ``'/'``-separated path.
     :type path: string
     :rtype: iterator of :class:`Distribution` instances"""
-    pass
+    for dist in get_distributions():
+        if dist.uses(path):
+            yield dist
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
@@ -13,6 +13,8 @@
 # TODO Add a test for getting a distribution that is provided by another
 #   distribution.
 
+# TODO Add a test for absolute pathed RECORD items (e.g. /etc/myapp/config.ini)
+
 class TestPkgUtilDistribution(unittest2.TestCase):
     """Tests the pkgutil.Distribution class"""
 
@@ -174,7 +176,8 @@
         # Setup the path environment with our fake distributions
         current_path = os.path.abspath(os.path.dirname(__file__))
         self.sys_path = sys.path[:]
-        sys.path[0:0] = [os.path.join(current_path, 'fake_dists')]
+        self.fake_dists_path = os.path.join(current_path, 'fake_dists')
+        sys.path[0:0] = [self.fake_dists_path]
 
     def tearDown(self):
         super(TestPkgUtilFunctions, self).tearDown()
@@ -244,9 +247,15 @@
         # Verify partial name matching doesn't work
         self.assertEqual(None, get_distribution('towel'))
 
-    def test_get_file_users(path):
-        """Test to determine which distributions use a file."""
-        pass
+    def test_get_file_users(self):
+        """Test the iteration of distributions that use a file."""
+        from distutils2._backport.pkgutil import get_file_users, Distribution
+        name = 'towel_stuff-0.1'
+        path = os.path.join(self.fake_dists_path, name,
+            'towel_stuff', '__init__.py')
+        for dist in get_file_users(path):
+            self.assertTrue(isinstance(dist, Distribution))
+            self.assertEqual(dist.name, name)
 
 
 def test_suite():

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


More information about the Python-checkins mailing list