def test_get_package_version(self): # Single item self.assertTrue( pip_utils.version_satisfies_spec( ">=7.0", pip_utils.get_package_version("pip")["pip"])) self.assertTrue("this package does not exist" not in pip_utils. get_package_version("this package does not exist")) self.assertTrue("blah" not in pip_utils.get_package_version( core.RequirementsFile("blah"))) self.assertTrue("blah" not in pip_utils.get_package_version( core.Dependency("blah", url="fake url"))) # Multiple different items multiple_different_items = pip_utils.get_package_version( ["pip", core.Dependency("wheel"), core.RequirementsFile("blah")]) self.assertTrue("pip" in multiple_different_items) self.assertTrue("wheel" in multiple_different_items) self.assertTrue("blah" not in multiple_different_items) # Multiple identical items multiple_identical_items = pip_utils.get_package_version( ["pip", core.Dependency("pip")]) self.assertTrue("pip" in multiple_identical_items) self.assertEqual(len(multiple_identical_items), 1) # Validate case lower_case_packages = pip_utils.get_package_version("PiP") self.assertTrue("pip" in lower_case_packages) self.assertTrue("pIp" not in lower_case_packages) self.assertTrue("PiP" not in lower_case_packages)
def test_pip_dependency_version(self): self.assertEqual( pip_utils.build_dependency_version_string( core.Dependency("test", "1.2.3")), ">=1.2.3") self.assertEqual( pip_utils.build_dependency_version_string( core.Dependency("test", ">=1.2.3,<=2.3.4")), "<=2.3.4,>=1.2.3") self.assertEqual(pip_utils.build_dependency_version_string("1.2.3"), "1.2.3") self.assertEqual(pip_utils.build_dependency_version_string(None), "")
def test_pip_dependency_version(self): self.assertEquals( pip_utils.build_dependency_version_string( core.Dependency("test", "1.2.3")), ">=1.2.3") self.assertEquals( pip_utils.build_dependency_version_string( core.Dependency("test", ">=1.2.3,<=2.3.4")), "<=2.3.4,>=1.2.3") self.assertEquals(pip_utils.build_dependency_version_string("1.2.3"), ">=1.2.3") self.assertEquals( pip_utils.build_dependency_version_string(">=1.2.3,<=2.3.4"), "<=2.3.4,>=1.2.3") self.assertRaises(ValueError, pip_utils.build_dependency_version_string, "bogus")