Commits

Anonymous committed cc83e56

Adding a check for invalid partial name matching in the get_distribution function test.

Comments (0)

Files changed (2)

src/distutils2/_backport/pkgutil.py

     value is expected. If the directory is not found, ``None`` is returned.
 
     :rtype: :class:`Distribution` or None"""
-    name = _normalize_dist_name(name)
-    dist = None
-    for path in sys.path:
-        realpath = os.path.realpath(path)
-        if not os.path.isdir(realpath):
-            continue
-        for dir in os.listdir(realpath):
-            dir_path = os.path.join(realpath, dir)
-            if dir.startswith(name) and os.path.isdir(dir_path):
-                dist = Distribution(dir_path)
-                break
-        if dist is not None:
+    found = None
+    for dist in get_distributions():
+        if dist.name == name:
+            found = dist
             break
-    return dist
+    return found
 
 def get_file_users(path):
     """

src/distutils2/_backport/tests/test_pkgutil.py

         self.assertListEqual(sorted(found_dists), sorted(fake_dists))
 
     def test_get_distribution(self):
-        """Lookup a distribution by name."""
+        """Test for looking up a distribution by name."""
         # Test the lookup of the towel-stuff distribution
         name = 'towel-stuff' # Note: This is different from the directory name
 
         # Verify that an unknown distribution returns None
         self.assertEqual(None, get_distribution('bogus'))
 
+        # Verify partial name matching doesn't work
+        self.assertEqual(None, get_distribution('towel'))
+
 
 def test_suite():
     suite = unittest2.TestSuite()