当前位置: 首页>>代码示例>>Python>>正文


Python depends.Depends类代码示例

本文整理汇总了Python中bindep.depends.Depends的典型用法代码示例。如果您正苦于以下问题:Python Depends类的具体用法?Python Depends怎么用?Python Depends使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Depends类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_platforms_include

    def test_platforms_include(self):
        # 9 tests for the nine cases of _include in Depends
        depends = Depends(dedent("""\
            # False, False -> False
            install1 [platform:dpkg quark]
            # False, None -> False
            install2 [platform:dpkg]
            # False, True -> False
            install3 [platform:dpkg test]
            # None, False -> False
            install4 [quark]
            # None, None -> True
            install5
            # None, True -> True
            install6 [test]
            # True, False -> False
            install7 [platform:rpm quark]
            # True, None -> True
            install8 [platform:rpm]
            # True, True -> True
            install9 [platform:rpm test]
            """))

        # With platform:dpkg and quark False and platform:rpm and test
        # True, the above mimics the conditions from _include.
        self.expectThat(
            set(r[0] for r in depends.active_rules(['platform:rpm', 'test'])),
            Equals({"install5", "install6", "install8", "install9"}))
开发者ID:openstack-infra,项目名称:bindep,代码行数:28,代码来源:test_depends.py

示例2: test_multiple_groups_only

 def test_multiple_groups_only(self):
     depends = Depends("foo [(bar baz) (quux)]\n")
     self.assertTrue(depends._evaluate(depends._rules[0][1],
                                       ["bar", "baz"]))
     self.assertTrue(depends._evaluate(depends._rules[0][1], ["quux"]))
     self.assertFalse(depends._evaluate(depends._rules[0][1], ["baz"]))
     self.assertFalse(depends._evaluate(depends._rules[0][1], ["bar"]))
开发者ID:openstack-infra,项目名称:bindep,代码行数:7,代码来源:test_depends.py

示例3: test_check_rule_present

 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", [], [])]))
开发者ID:dtroyer,项目名称:bindep,代码行数:8,代码来源:test_depends.py

示例4: test_detects_opensuse_leap15

 def test_detects_opensuse_leap15(self):
     with DistroFixture("openSUSEleap15"):
         depends = Depends("")
         platform_profiles = depends.platform_profiles()
         self.assertThat(platform_profiles,
                         Contains("platform:opensuse"))
         self.assertThat(platform_profiles,
                         Contains("platform:suse"))
开发者ID:openstack-infra,项目名称:bindep,代码行数:8,代码来源:test_depends.py

示例5: test_check_rule_present

 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")
开发者ID:openstack-infra,项目名称:bindep,代码行数:8,代码来源:test_depends.py

示例6: test_parser_accepts_full_path_to_tools

 def test_parser_accepts_full_path_to_tools(self):
     # at least yum/dnf allow these instead of mentioning rpm names
     depends = Depends(dedent("""\
         /usr/bin/bash
         """))
     self.assertEqual(
         [("/usr/bin/bash", [], [])],
         depends.active_rules(["default"]))
开发者ID:openstack-infra,项目名称:bindep,代码行数:8,代码来源:test_depends.py

示例7: test_detects_unknown

 def test_detects_unknown(self):
     with DistroFixture("Unknown"):
         depends = Depends("")
         self.assertThat(
             depends.platform_profiles(), Contains("platform:unknown"))
         with ExpectedException(Exception,
                                "Uknown package manager for "
                                "current platform."):
             depends.platform.get_pkg_version('x')
开发者ID:openstack-infra,项目名称:bindep,代码行数:9,代码来源:test_depends.py

示例8: test_check_rule_incompatible

 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")])]))
开发者ID:dtroyer,项目名称:bindep,代码行数:10,代码来源:test_depends.py

示例9: test_finds_profiles

 def test_finds_profiles(self):
     depends = Depends(dedent("""\
         foo
         bar [something]
         quux [anotherthing !nothing] <=12
         """))
     self.assertThat(
         depends.profiles(),
         MatchesSetwise(*map(
             Equals, ["something", "anotherthing", "nothing"])))
开发者ID:openstack-infra,项目名称:bindep,代码行数:10,代码来源:test_depends.py

示例10: test_check_rule_missing_version

 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")
开发者ID:openstack-infra,项目名称:bindep,代码行数:10,代码来源:test_depends.py

示例11: test_detects_rhel_workstation

 def test_detects_rhel_workstation(self):
     with DistroFixture("RHELWorkstation"):
         depends = Depends("")
         platform_profiles = depends.platform_profiles()
         self.assertThat(
             platform_profiles,
             Contains("platform:redhatenterpriseworkstation"))
         self.assertThat(
             platform_profiles,
             Contains("platform:rhel"))
         self.assertThat(
             platform_profiles,
             Contains("platform:redhat"))
开发者ID:openstack-infra,项目名称:bindep,代码行数:13,代码来源:test_depends.py

示例12: test_platforms

    def test_platforms(self):
        depends = Depends(dedent("""\
            install1
            install2 [test]
            install3 [platform:rpm]
            install4 [platform:dpkg]
            install5 [quark]
            install6 [platform:dpkg test]
            install7 [quark test]
            install8 [platform:dpkg platform:rpm]
            install9 [platform:dpkg platform:rpm test]
            installA [!platform:dpkg]
            installB [!platform:dpkg test]
            installC [!platform:dpkg !test]
            installD [platform:dpkg !test]
            installE [platform:dpkg !platform:rpm]
            installF [platform:dpkg !platform:rpm test]
            installG [!platform:dpkg !platform:rpm]
            installH [!platform:dpkg !platform:rpm test]
            installI [!platform:dpkg !platform:rpm !test]
            installJ [platform:dpkg !platform:rpm !test]
            """))

        # Platform-only rules and rules with no platform are activated
        # by a matching platform.
        self.expectThat(
            set(r[0] for r in depends.active_rules(['platform:dpkg'])),
            Equals({"install1", "install4", "install8", "installD",
                    "installE", "installJ"}))

        # Non-platform rules matching one-or-more profiles plus any
        # matching platform guarded rules.
        self.expectThat(
            set(r[0] for r in depends.active_rules(['platform:dpkg', 'test'])),
            Equals({"install1", "install2", "install4", "install6", "install7",
                    "install8", "install9", "installE", "installF"}))

        # When multiple platforms are present, none-or-any-platform is
        # enough to match.
        self.expectThat(
            set(r[0] for r in depends.active_rules(['platform:rpm'])),
            Equals({"install1", "install3", "install8", "installA",
                    "installC"}))

        # If there are any platform profiles on a rule one of them
        # must match an active platform even when other profiles match
        # for the rule to be active.
        self.expectThat(
            set(r[0] for r in depends.active_rules(['platform:rpm', 'test'])),
            Equals({"install1", "install2", "install3", "install7", "install8",
                    "install9", "installA", "installB"}))
开发者ID:openstack-infra,项目名称:bindep,代码行数:51,代码来源:test_depends.py

示例13: test_detects_opensuse_project

 def test_detects_opensuse_project(self):
     # TODO what does an os-release for opensuse project look like?
     # Is this different than sles, leap, and tumbleweed?
     with DistroFixture("openSUSEleap"):
         depends = Depends("")
         platform_profiles = depends.platform_profiles()
         self.assertThat(platform_profiles,
                         Contains("platform:opensuseproject"))
         self.assertThat(platform_profiles,
                         Contains("platform:opensuse"))
         self.assertThat(platform_profiles,
                         Contains("platform:opensuseproject-42.1"))
         self.assertThat(platform_profiles,
                         Contains("platform:suse"))
开发者ID:openstack-infra,项目名称:bindep,代码行数:14,代码来源:test_depends.py

示例14: test_parser_patterns

    def test_parser_patterns(self):
        depends = Depends(dedent("""\
            foo
            bar [something]
            category/packagename # for gentoo
            baz [platform:this platform:that-those]
            blaz [platform:rpm !platform:opensuseproject-42.2]
            quux [anotherthing !nothing] <=12
            womp # and a comment
            # a standalone comment and a blank line

            # all's ok? good then
            """))
        self.assertEqual(len(depends.active_rules(['default'])), 3)
开发者ID:openstack-infra,项目名称:bindep,代码行数:14,代码来源:test_depends.py

示例15: main

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
开发者ID:pombredanne,项目名称:bindep,代码行数:38,代码来源:main.py


注:本文中的bindep.depends.Depends类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。