本文整理匯總了Python中bindep.depends.Depends.check_rules方法的典型用法代碼示例。如果您正苦於以下問題:Python Depends.check_rules方法的具體用法?Python Depends.check_rules怎麽用?Python Depends.check_rules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bindep.depends.Depends
的用法示例。
在下文中一共展示了Depends.check_rules方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_check_rule_present
# 需要導入模塊: from bindep.depends import Depends [as 別名]
# 或者: from bindep.depends.Depends import check_rules [as 別名]
def test_check_rule_present(self):
depends = Depends("")
depends.platform = mock.MagicMock()
mock_depend_platform = self.useFixture(
fixtures.MockPatchObject(depends.platform, 'get_pkg_version',
return_value="123")).mock
self.assertEqual([], depends.check_rules([("foo", [], [])]))
mock_depend_platform.assert_called_once_with("foo")
示例2: test_check_rule_present
# 需要導入模塊: from bindep.depends import Depends [as 別名]
# 或者: from bindep.depends.Depends import check_rules [as 別名]
def test_check_rule_present(self):
depends = Depends("")
mocker = mox.Mox()
depends.platform = mocker.CreateMock(Platform)
depends.platform.get_pkg_version("foo").AndReturn("123")
mocker.ReplayAll()
self.addCleanup(mocker.VerifyAll)
self.assertEqual([], depends.check_rules([("foo", [], [])]))
示例3: test_check_rule_missing_version
# 需要導入模塊: from bindep.depends import Depends [as 別名]
# 或者: from bindep.depends.Depends import check_rules [as 別名]
def test_check_rule_missing_version(self):
depends = Depends("")
depends.platform = mock.MagicMock()
mock_depend_platform = self.useFixture(
fixtures.MockPatchObject(depends.platform, 'get_pkg_version',
return_value=None)).mock
self.assertEqual(
[('missing', ['foo'])],
depends.check_rules([("foo", [], [(">=", "1.2.3")])]))
mock_depend_platform.assert_called_once_with("foo")
示例4: test_check_rule_incompatible
# 需要導入模塊: from bindep.depends import Depends [as 別名]
# 或者: from bindep.depends.Depends import check_rules [as 別名]
def test_check_rule_incompatible(self):
depends = Depends("")
mocker = mox.Mox()
depends.platform = mocker.CreateMock(Platform)
depends.platform.get_pkg_version("foo").AndReturn("123")
mocker.ReplayAll()
self.addCleanup(mocker.VerifyAll)
self.assertEqual(
[('badversion', [('foo', "!=123", "123")])],
depends.check_rules([("foo", [], [("!=", "123")])]))
示例5: main
# 需要導入模塊: from bindep.depends import Depends [as 別名]
# 或者: from bindep.depends.Depends import check_rules [as 別名]
def main(depends=None):
if depends is None:
try:
content = open("other-requirements.txt", "rt").read()
except IOError:
logging.error("No other-requirements.txt file found.")
return 1
depends = Depends(content)
parser = optparse.OptionParser()
parser.add_option("--profiles", action="store_true", help="List the platform and configuration profiles.")
opts, args = parser.parse_args()
if opts.profiles:
logging.info("Platform profiles:")
for profile in depends.platform_profiles():
logging.info("%s", profile)
logging.info("")
logging.info("Configuration profiles:")
for profile in depends.profiles():
logging.info("%s", profile)
else:
if args:
profiles = args
else:
profiles = ["default"]
profiles = profiles + depends.platform_profiles()
rules = depends.active_rules(profiles)
errors = depends.check_rules(rules)
for error in errors:
if error[0] == "missing":
logging.info("Missing packages:")
logging.info(" %s", " ".join(error[1]))
if error[0] == "badversion":
logging.info("Bad versions of installed packages:")
for pkg, constraint, version in error[1]:
logging.info(" %s version %s does not match %s", pkg, version, constraint)
if errors:
return 1
return 0