本文整理汇总了Python中enstaller.repository.Repository.find_package_from_requirement方法的典型用法代码示例。如果您正苦于以下问题:Python Repository.find_package_from_requirement方法的具体用法?Python Repository.find_package_from_requirement怎么用?Python Repository.find_package_from_requirement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enstaller.repository.Repository
的用法示例。
在下文中一共展示了Repository.find_package_from_requirement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRepository
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import find_package_from_requirement [as 别名]
#.........这里部分代码省略.........
# Then
self.assertEqual(len(list(repository.iter_packages())), 0)
def test_delete_non_existing(self):
# Given
path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")
to_remove = PackageMetadata.from_egg(path)
repository = Repository()
# When/Then
with self.assertRaises(NoSuchPackage):
repository.delete_package(to_remove)
def test_delete_simple(self):
# Given
eggs = ["flake8-2.0.0-2.egg", "nose-1.3.0-1.egg", "nose-1.2.1-1.egg"]
repository = Repository()
for egg in eggs:
path = os.path.join(_EGGINST_COMMON_DATA, egg)
package = RemotePackageMetadata.from_egg(path)
repository.add_package(package)
path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")
to_remove = PackageMetadata.from_egg(path)
# When
repository.delete_package(to_remove)
# Then
assertCountEqual(self, [p.key for p in repository.iter_packages()],
["flake8-2.0.0-2.egg", "nose-1.2.1-1.egg"])
def test_find_package_from_requirement_name_only(self):
# Given
requirement = Requirement.from_legacy_requirement_string("nose")
# When
package = self.repository.find_package_from_requirement(requirement)
# Then
self.assertEqual(package.full_version, "1.3.0-2")
def test_find_package_from_requirement_name_and_version(self):
# Given
requirement = Requirement.from_legacy_requirement_string("nose 1.3.0")
# When
package = self.repository.find_package_from_requirement(requirement)
# Then
self.assertEqual(package.full_version, "1.3.0-2")
# Given
requirement = Requirement.from_legacy_requirement_string("nose 1.2.1")
# When
package = self.repository.find_package_from_requirement(requirement)
# Then
self.assertEqual(package.full_version, "1.2.1-1")
def test_find_package_from_requirement_missing(self):
# Given
requirement_strings = ["fubar", "nose 1.3.1"]
示例2: TestRepository
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import find_package_from_requirement [as 别名]
#.........这里部分代码省略.........
packages = repository.find_packages("dummy")
self.assertEqual(len(packages), 1)
self.assertEqual(packages[0].name, "dummy")
def test_from_empty_prefix(self):
# Given
with mkdtemp() as tempdir:
# When
repository = Repository._from_prefixes([tempdir])
# Then
self.assertEqual(len(list(repository.iter_packages())), 0)
def test_delete_non_existing(self):
# Given
path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")
to_remove = PackageMetadata.from_egg(path)
repository = Repository()
# When/Then
with self.assertRaises(NoSuchPackage):
repository.delete_package(to_remove)
def test_delete_simple(self):
# Given
eggs = ["flake8-2.0.0-2.egg", "nose-1.3.0-1.egg", "nose-1.2.1-1.egg"]
repository = Repository()
for egg in eggs:
path = os.path.join(_EGGINST_COMMON_DATA, egg)
package = RepositoryPackageMetadata.from_egg(path)
repository.add_package(package)
path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")
to_remove = PackageMetadata.from_egg(path)
# When
repository.delete_package(to_remove)
# Then
assertCountEqual(self, [p.key for p in repository.iter_packages()],
["flake8-2.0.0-2.egg", "nose-1.2.1-1.egg"])
def test_find_package_from_requirement_name_only(self):
# Given
requirement = Requirement.from_anything("nose")
# When
package = self.repository.find_package_from_requirement(requirement)
# Then
self.assertEqual(package.full_version, "1.3.0-2")
def test_find_package_from_requirement_name_and_version(self):
# Given
requirement = Requirement.from_anything("nose 1.3.0")
# When
package = self.repository.find_package_from_requirement(requirement)
# Then
self.assertEqual(package.full_version, "1.3.0-2")
# Given
requirement = Requirement.from_anything("nose 1.2.1")
# When
package = self.repository.find_package_from_requirement(requirement)
# Then
self.assertEqual(package.full_version, "1.2.1-1")
def test_find_package_from_requirement_missing(self):
# Given
requirement_strings = ["fubar", "nose 1.3.1"]
# When
for requirement_string in requirement_strings:
requirement = Requirement.from_anything(requirement_string)
with self.assertRaises(NoSuchPackage):
self.repository.find_package_from_requirement(requirement)
def test_find_package_from_requirement_all(self):
# Given
requirement = Requirement.from_anything("nose 1.3.0-1")
# When
package = self.repository.find_package_from_requirement(requirement)
# Then
self.assertEqual(package.full_version, "1.3.0-1")
# Given
requirement = Requirement.from_anything("nose 1.2.1-1")
# When
package = self.repository.find_package_from_requirement(requirement)
# Then
self.assertEqual(package.full_version, "1.2.1-1")
示例3: TestRepository
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import find_package_from_requirement [as 别名]
#.........这里部分代码省略.........
# Then
self.assertEqual(len(list(repository.iter_packages())), 0)
def test_delete_non_existing(self):
# Given
path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")
to_remove = PackageMetadata.from_egg(path)
repository = Repository()
# When/Then
with self.assertRaises(NoSuchPackage):
repository.delete_package(to_remove)
def test_delete_simple(self):
# Given
eggs = ["flake8-2.0.0-2.egg", "nose-1.3.0-1.egg", "nose-1.2.1-1.egg"]
repository = Repository()
for egg in eggs:
path = os.path.join(_EGGINST_COMMON_DATA, egg)
package = RemotePackageMetadata.from_egg(path)
repository.add_package(package)
path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")
to_remove = PackageMetadata.from_egg(path)
# When
repository.delete_package(to_remove)
# Then
assertCountEqual(self, [p.key for p in repository.iter_packages()],
["flake8-2.0.0-2.egg", "nose-1.2.1-1.egg"])
def test_find_package_from_requirement_name_only(self):
# Given
requirement = Requirement.from_anything("nose")
# When
package = self.repository.find_package_from_requirement(requirement)
# Then
self.assertEqual(package.full_version, "1.3.0-2")
def test_find_package_from_requirement_name_and_version(self):
# Given
requirement = Requirement.from_anything("nose 1.3.0")
# When
package = self.repository.find_package_from_requirement(requirement)
# Then
self.assertEqual(package.full_version, "1.3.0-2")
# Given
requirement = Requirement.from_anything("nose 1.2.1")
# When
package = self.repository.find_package_from_requirement(requirement)
# Then
self.assertEqual(package.full_version, "1.2.1-1")
def test_find_package_from_requirement_missing(self):
# Given
requirement_strings = ["fubar", "nose 1.3.1"]