Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_version_satisfies_spec(self):
self.assertEqual(pip_utils.version_satisfies_spec(None, "blah"), True)
self.assertEqual(pip_utils.version_satisfies_spec("blah", None), False)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.2.3", "1.2.4"), True)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.2.3", "1.2.4.dev987"), False)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.0", "1.1.dev1"), False)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.0,>=0.0.dev0", "1.1.dev1"), True)
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)
def test_version_satisfies_spec(self):
self.assertEqual(pip_utils.version_satisfies_spec(None, "blah"), True)
self.assertEqual(pip_utils.version_satisfies_spec("blah", None), False)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.2.3", "1.2.4"), True)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.2.3", "1.2.4.dev987"), False)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.0", "1.1.dev1"), False)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.0,>=0.0.dev0", "1.1.dev1"), True)
def test_version_satisfies_spec(self):
self.assertEqual(pip_utils.version_satisfies_spec(None, "blah"), True)
self.assertEqual(pip_utils.version_satisfies_spec("blah", None), False)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.2.3", "1.2.4"), True)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.2.3", "1.2.4.dev987"), False)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.0", "1.1.dev1"), False)
self.assertEqual(pip_utils.version_satisfies_spec(">=1.0,>=0.0.dev0", "1.1.dev1"), True)
def _check_plugin_version(plugin_module, plugin_name):
if hasattr(plugin_module, "pyb_version") and plugin_module.pyb_version:
if not pip_utils.version_satisfies_spec(plugin_module.pyb_version, PYB_VERSION):
raise IncompatiblePluginException(plugin_name, plugin_module.pyb_version, PYB_VERSION)
if pip_utils.should_update_package(dependency.version) \
and not getattr(dependency, "version_not_a_spec", False):
# Always add dependency that has a version specifier indicating desire to always update
logger.debug("Dependency '%s' has a non-exact version specifier and will be included" % dependency)
dependencies_to_install.append(dependency)
continue
dependency_name = dependency.name.lower()
if dependency_name not in installed_packages:
# If dependency not installed at all then install it
logger.debug("Dependency '%s' is not installed and will be included" % dependency)
dependencies_to_install.append(dependency)
continue
if dependency.version \
and not pip_utils.version_satisfies_spec(dependency.version, installed_packages[dependency_name]):
# If version is specified and version constraint is not satisfied
logger.debug("Dependency '%s' is not satisfied by installed dependency version '%s' and will be included" %
(dependency, installed_packages[dependency_name]))
dependencies_to_install.append(dependency)
continue
logger.debug("Dependency '%s' is already up-to-date and will be skipped" % dependency)
return dependencies_to_install, installed_packages, dependency_constraints