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


Python support.command_run函数代码示例

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


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

示例1: test_add_from_repofile

    def test_add_from_repofile(self):
        tempfile_kwargs = {"mode": "w", "suffix": ".repo", "delete": False}
        if dnf.pycomp.PY3:
            tempfile_kwargs["encoding"] = "utf8"

        repofile = tempfile.NamedTemporaryFile(**tempfile_kwargs)
        dnf.pycomp.write_to_file(repofile, REPOCONTENT)
        repofile.close()

        command_run(self.cmd, ["--add-repo", repofile.name])

        installed_repofile = os.path.join(self.cmd.base.conf.reposdir[0], os.path.basename(repofile.name))
        with open(installed_repofile) as f:
            added = f.read()

        self.assertMultiLineEqual(REPOCONTENT, added)

        def get_matching(x):
            repo = dnf.repo.Repo(x, self.cmd.base.conf)
            repo.repofile = installed_repofile
            repo.cfg = iniparse.compat.RawConfigParser()
            repo.cfg.read(installed_repofile)
            return [repo]

        self.cmd.base.repos.get_matching = get_matching
        self.cmd.base.output = dnf.cli.output.Output(self.cmd.base, self.cmd.base.conf)

        self.subtest_disable(REPOLABEL, installed_repofile)
        self.subtest_enable(REPOLABEL, installed_repofile)

        os.unlink(repofile.name)
开发者ID:pnemade,项目名称:dnf-plugins-core,代码行数:31,代码来源:test_config_manager.py

示例2: test

    def test(self):
        """Test whether only upgrades in the repository are listed."""
        for pkg in self.cli.base.sack.query().installed().filter(name='tour'):
            self.cli.base._yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.cli.base._yumdb.get_package(pkg).from_repo = 'updates'

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['updates', 'check-update'])

        self.assertEqual(
            stdout.getvalue(),
            u'\n'
            u'hole.x86_64                              1-2'
            u'                            updates \n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'pepper.x86_64                            20-1'
            u'                           updates \n'
            u'Obsoleting Packages\n'
            u'hole.i686                                2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n')
        self.assertEqual(self.cli.demands.success_exit_status, 100)
开发者ID:Conan-Kudo,项目名称:dnf,代码行数:29,代码来源:test_commands.py

示例3: test_add_from_repofile

    def test_add_from_repofile(self):
        tempfile_kwargs = {'mode': 'w', 'suffix': '.repo', 'delete': False}
        if dnf.pycomp.PY3:
            tempfile_kwargs['encoding'] = 'utf8'

        repofile = tempfile.NamedTemporaryFile(**tempfile_kwargs)
        dnf.pycomp.write_to_file(repofile, REPOCONTENT)
        repofile.close()

        command_run(self.cmd, ['--add-repo', repofile.name])

        installed_repofile = os.path.join(self.cmd.base.conf.reposdir[0],
                                          os.path.basename(repofile.name))
        with open(installed_repofile) as f:
            added = f.read()

        self.assertMultiLineEqual(REPOCONTENT, added)

        def get_matching(x):
            repo = dnf.repo.Repo(x, self.cmd.base.conf)
            repo.repofile = installed_repofile
            return [repo]
        self.cmd.base.repos.get_matching = get_matching
        self.cmd.base.output = dnf.cli.output.Output(self.cmd.base, self.cmd.base.conf)

        self.subtest_disable(REPOLABEL, installed_repofile)
        self.subtest_enable(REPOLABEL, installed_repofile)

        os.unlink(repofile.name)
开发者ID:rpm-software-management,项目名称:dnf-plugins-core,代码行数:29,代码来源:test_config_manager.py

示例4: subtest_disable

    def subtest_disable(self, label, fname):
        command_run(self.cmd, ["--set-disabled", label])

        with open(fname) as f:
            added = f.read()
        disabled = REPOCONTENT.replace("enabled=1", "enabled=0")
        self.assertMultiLineEqual(disabled, added)
开发者ID:pnemade,项目名称:dnf-plugins-core,代码行数:7,代码来源:test_config_manager.py

示例5: test_all_reinstallold

    def test_all_reinstallold(self):
        """Test whether only reinstall-old is called."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['main', 'reinstall'])

        self.assertEqual(self.mock.mock_calls,
                         [mock.call.reinstall_old_run()])
开发者ID:Conan-Kudo,项目名称:dnf,代码行数:7,代码来源:test_commands.py

示例6: test_split_extcmds

 def test_split_extcmds(self):
     cmd = group.GroupCommand(support.mock.MagicMock())
     cmd.base.conf = dnf.conf.Conf()
     support.command_run(cmd, ['install', 'crack'])
     cmd.base.env_group_install.assert_called_with(
         ['crack'], ('mandatory', 'default', 'conditional'),
         cmd.base.conf.strict)
开发者ID:edynox,项目名称:dnf,代码行数:7,代码来源:test_group.py

示例7: test_info_upgrades

 def test_info_upgrades(self):
     """Test whether only upgrades in the repository are listed."""
     cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
     with support.patch_std_streams() as (stdout, _):
         support.command_run(cmd, ['updates', 'info', 'upgrades'])
     self.assertEqual(stdout.getvalue(), ''.join((
         u'Available Upgrades\n', self.HOLE_X86_64_INFO, self.PEPPER_UPDATES_INFO)))
开发者ID:edynox,项目名称:dnf,代码行数:7,代码来源:test_commands.py

示例8: test_run

    def test_run(self):
        """Test whether a package is updated."""
        support.command_run(self.cmd, ['pepper'])

        self.assertResult(self.cmd.base, itertools.chain(
            self.cmd.base.sack.query().installed().filter(name__neq='pepper'),
            self.cmd.base.sack.query().upgrades().filter(name='pepper')))
开发者ID:Conan-Kudo,项目名称:dnf,代码行数:7,代码来源:test_commands.py

示例9: test

    def test(self):
        """ Test whether only upgrades in the repository are listed. """
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed().filter(name='tour'):
            mockSwdbPkg(history, pkg, repo='updates')

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['updates', 'check-update'])

        self.assertEqual(
            stdout.getvalue(),
            u'\n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'pepper.x86_64                            20-1'
            u'                           updates \n'
            u'Obsoleting Packages\n'
            u'hole.i686                                2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n')
        self.assertEqual(self.cli.demands.success_exit_status, 100)
开发者ID:edynox,项目名称:dnf,代码行数:27,代码来源:test_commands.py

示例10: test_run_package

    def test_run_package(self):
        """Test whether a package is installed."""
        support.command_run(self._cmd, ['lotus'])

        base = self._cmd.cli.base
        self.assertResult(base, itertools.chain(
              base.sack.query().installed(),
              dnf.subject.Subject('lotus.x86_64').get_best_query(base.sack)))
开发者ID:Conan-Kudo,项目名称:dnf,代码行数:8,代码来源:test_commands.py

示例11: test_space_option

 def test_space_option(self):
     args = ["--new", "--space", self.path]
     with mock.patch("sys.stdout", new_callable=dnf.pycomp.StringIO) as stdout:
         support.command_run(self.cmd, args)
         expected_list = ["foo-4-8.src.rpm",
                          "noarch/foo-4-8.noarch.rpm"]
         self.assertEqual(stdout.getvalue()[:-1],
             " ".join(self._path_join_in_list(expected_list, self.path)))
开发者ID:j-mracek,项目名称:dnf-plugins-extras,代码行数:8,代码来源:test_repomanage.py

示例12: test_run_group

    def test_run_group(self):
        """Test whether a group is installed."""
        support.command_run(self._cmd, ['@Solid Ground'])

        base = self._cmd.cli.base
        self.assertResult(base, itertools.chain(
              base.sack.query().installed(),
              dnf.subject.Subject('trampoline').get_best_query(base.sack)))
开发者ID:Conan-Kudo,项目名称:dnf,代码行数:8,代码来源:test_commands.py

示例13: test_base

 def test_base(self):
     args = []
     self.cmd.base.add_remote_rpms([os.path.join(self.path, "noarch/foo-4-6.noarch.rpm")])
     with mock.patch("sys.stdout", new_callable=dnf.pycomp.StringIO) as stdout:
         support.command_run(self.cmd, args)
         expected_out = ["package: foo-4-6.noarch from @commandline",
                         "  unresolved deps:",
                         "    bar = 4-6"]
         self.assertEqual(stdout.getvalue()[:-1], "\n".join(expected_out))
开发者ID:jsilhan,项目名称:dnf-plugins-core,代码行数:9,代码来源:test_repoclosure.py

示例14: test_all

    def test_all(self):
        """Test whether all packages from the repository are installed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['third_party', 'upgrade'])

        self.assertResult(self.cli.base, itertools.chain(
            self.cli.base.sack.query().installed().filter(name__neq='hole'),
            self.cli.base.sack.query().upgrades().filter(reponame='third_party',
                                                         arch='x86_64')))
开发者ID:Conan-Kudo,项目名称:dnf,代码行数:9,代码来源:test_commands.py

示例15: test_canonical

 def test_canonical(self):
     cmd = dnf.cli.commands.upgrade.UpgradeCommand(
                             support.BaseCliStub('main').mock_cli())
     try:
         support.command_run(cmd, ['cracker', 'filling'])
     except dnf.exceptions.Error as e:
         if e.value != 'No packages marked for upgrade.':
             raise
     self.assertEqual(cmd.basecmd, 'upgrade')
     self.assertEqual(cmd.opts.pkg_specs, ['cracker', 'filling'])
开发者ID:Conan-Kudo,项目名称:dnf,代码行数:10,代码来源:test_commands.py


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