Esempio n. 1
0
    def test_cross_check_unparseable_versions(self):
        # The bug in #1355 is triggered when a version string from either pkg_resources or import
        # is not parseable at all by normalized_version.

        res = cross_check({"foo": ("unparseable", "")},
                          [("foo", ("1.0", "", None))])
        self.failUnlessEqual(res, [])

        res = cross_check({"foo": ("1.0", "")},
                          [("foo", ("unparseable", "", None))])
        self.failUnlessEqual(res, [])

        res = cross_check({"foo": ("unparseable", "")},
                          [("foo", ("unparseable", "", None))])
        self.failUnlessEqual(res, [])
Esempio n. 2
0
    def test_cross_check(self):
        res = cross_check({}, [])
        self.failUnlessEqual(res, [])

        res = cross_check({}, [("tahoe-lafs", ("1.0", "", "blah"))])
        self.failUnlessEqual(res, [])

        res = cross_check({"foo": ("unparseable", "")}, [])
        self.failUnlessEqual(res, [])

        res = cross_check({"argparse": ("unparseable", "")}, [])
        self.failUnlessEqual(res, [])

        res = cross_check({}, [("foo", ("unparseable", "", None))])
        self.failUnlessEqual(len(res), 1)
        self.assertTrue(("version 'unparseable'" in res[0])
                        or ("version u'unparseable'" in res[0]))
        self.failUnlessIn("was not found by pkg_resources", res[0])

        res = cross_check({"distribute": ("1.0", "/somewhere")},
                          [("setuptools",
                            ("2.0", "/somewhere", "distribute"))])
        self.failUnlessEqual(res, [])

        res = cross_check({"distribute": ("1.0", "/somewhere")},
                          [("setuptools", ("2.0", "/somewhere", None))])
        self.failUnlessEqual(len(res), 1)
        self.failUnlessIn("location mismatch", res[0])

        res = cross_check({"distribute": ("1.0", "/somewhere")},
                          [("setuptools",
                            ("2.0", "/somewhere_different", None))])
        self.failUnlessEqual(len(res), 1)
        self.failUnlessIn("location mismatch", res[0])

        res = cross_check({"zope.interface": ("1.0", "")},
                          [("zope.interface", ("unknown", "", None))])
        self.failUnlessEqual(res, [])

        res = cross_check({"zope.interface": ("unknown", "")},
                          [("zope.interface", ("unknown", "", None))])
        self.failUnlessEqual(res, [])

        res = cross_check({"foo": ("1.0", "")},
                          [("foo", ("unknown", "", None))])
        self.failUnlessEqual(len(res), 1)
        self.failUnlessIn("could not find a version number", res[0])

        res = cross_check({"foo": ("unknown", "")},
                          [("foo", ("unknown", "", None))])
        self.failUnlessEqual(res, [])

        # When pkg_resources and import both find a package, there is only a warning if both
        # the version and the path fail to match.

        res = cross_check({"foo": ("1.0", "/somewhere")},
                          [("foo", ("2.0", "/somewhere", None))])
        self.failUnlessEqual(res, [])

        res = cross_check({"foo": ("1.0", "/somewhere")},
                          [("foo", ("1.0", "/somewhere_different", None))])
        self.failUnlessEqual(res, [])

        res = cross_check({"foo": ("1.0-r123", "/somewhere")},
                          [("foo",
                            ("1.0.post123", "/somewhere_different", None))])
        self.failUnlessEqual(res, [])

        res = cross_check({"foo": ("1.0", "/somewhere")},
                          [("foo", ("2.0", "/somewhere_different", None))])
        self.failUnlessEqual(len(res), 1)
        self.assertTrue(("but version '2.0'" in res[0])
                        or ("but version u'2.0'" in res[0]))