+ def test_packages_from_pkg_resources(self):
+ if hasattr(sys, 'frozen'):
+ raise unittest.SkipTest("This test doesn't apply to frozen builds.")
+
+ class MockPackage(object):
+ def __init__(self, project_name, version, location):
+ self.project_name = project_name
+ self.version = version
+ self.location = location
+
+ def call_pkg_resources_require(*args):
+ return [MockPackage("Foo", "1.0", "/path")]
+ self.patch(pkg_resources, 'require', call_pkg_resources_require)
+
+ (packages, errors) = get_package_versions_and_locations()
+ self.failUnlessIn(("foo", ("1.0", "/path", "according to pkg_resources")), packages)
+ self.failIfEqual(errors, [])
+ self.failUnlessEqual([e for e in errors if "was not found by pkg_resources" not in e], [])
+