• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python support.patch_std_streams函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: test_setup

 def test_setup(self):
     logger = logging.getLogger("dnf")
     with support.patch_std_streams() as (stdout, stderr):
         self.logging.setup(logging.INFO, logging.ERROR, self.logdir)
         self._bench(logger)
     self.assertEqual("i\n", stdout.getvalue())
     self.assertEqual("e\n", stderr.getvalue())
开发者ID:PaulReiber,项目名称:dnf,代码行数:7,代码来源:test_logging.py


示例3: test_setup_verbose

 def test_setup_verbose(self):
     logger = logging.getLogger("dnf")
     with support.patch_std_streams() as (stdout, stderr):
         self.logging.setup(logging.DEBUG, logging.WARNING, self.logdir)
         self._bench(logger)
     self.assertEqual("d\ni\n", stdout.getvalue())
     self.assertEqual("w\ne\n", stderr.getvalue())
开发者ID:PaulReiber,项目名称:dnf,代码行数:7,代码来源:test_logging.py


示例4: 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


示例5: test_configure_badargs

 def test_configure_badargs(self):
     """Test whether the command fail in case of wrong args."""
     with self.assertRaises(SystemExit) as exit, \
         support.patch_std_streams() as (stdout, stderr), \
         mock.patch('logging.Logger.critical') as clog:
         support.command_configure(self.cmd, [])
     self.assertEqual(exit.exception.code, 1)
开发者ID:Conan-Kudo,项目名称:dnf,代码行数:7,代码来源:test_commands.py


示例6: 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


示例7: test

    def test(self):
        """Test whether only upgrades in the repository are listed."""
        cmd = dnf.cli.commands.RepoPkgsCommand.CheckUpdateSubCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            cmd.run_on_repo('updates', [])

        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'                            @System\n'
            u'hole.x86_64                               2-1'
            u'                            updates\n'
            u'    tour.noarch                           5-0'
            u'                            @System\n')
        self.assertEqual(self.cli.demands.success_exit_status, 100)
开发者ID:Xake,项目名称:dnf,代码行数:25,代码来源:test_commands.py


示例8: test_obsoleted

 def test_obsoleted(self):
     self.cmd = dnf.cli.commands.check.CheckCommand(
         support.CliStub(support.BaseCliStub()))
     support.command_configure(self.cmd, ['--obsoleted'])
     with support.patch_std_streams() as (stdout, _):
         with self.assertRaises(dnf.exceptions.Error) as ctx:
             self.cmd.run()
         self.assertEqual(str(ctx.exception),
                          'Check discovered 1 problem(s)')
     self.assertEqual(stdout.getvalue(), EXPECTED_OBSOLETED_FORMAT)
开发者ID:AdamWill,项目名称:dnf,代码行数:10,代码来源:test_check.py


示例9: test_info_obsoletes

    def test_info_obsoletes(self):
        """Test whether only obsoletes in the repository are listed."""
        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['obsoletes'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                u'Obsoleting Packages\n',
                self.HOLE_I686_INFO,
                self.HOLE_X86_64_INFO)))
开发者ID:auchytil,项目名称:dnf,代码行数:11,代码来源:test_commands.py


示例10: test_info_obsoletes

    def test_info_obsoletes(self):
        """Test whether only obsoletes 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', 'obsoletes'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                u'Obsoleting Packages\n',
                self.HOLE_I686_INFO,
                self.HOLE_X86_64_INFO)))
开发者ID:Conan-Kudo,项目名称:dnf,代码行数:12,代码来源:test_commands.py


示例11: test_info_installed

    def test_info_installed(self):
        """Test whether only packages installed from the repository are listed."""
        for pkg in self._cmd.base.sack.query().installed().filter(name='pepper'):
            self._cmd.base.yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self._cmd.base.yumdb.get_package(pkg).from_repo = 'main'

        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('main', ['installed'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((self.INSTALLED_TITLE, self.PEPPER_SYSTEM_INFO)))
开发者ID:auchytil,项目名称:dnf,代码行数:12,代码来源:test_commands.py


示例12: test_info_available

    def test_info_available(self):
        """Test whether only packages in the repository are listed."""
        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['available'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                self.AVAILABLE_TITLE,
                self.HOLE_I686_INFO,
                self.HOLE_X86_64_INFO,
                self.PEPPER_UPDATES_INFO)))
开发者ID:auchytil,项目名称:dnf,代码行数:12,代码来源:test_commands.py


示例13: test_info_available

    def test_info_available(self):
        """Test whether only packages 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', 'available'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                self.AVAILABLE_TITLE,
                self.HOLE_I686_INFO,
                self.HOLE_X86_64_INFO,
                self.PEPPER_UPDATES_INFO)))
开发者ID:Conan-Kudo,项目名称:dnf,代码行数:13,代码来源:test_commands.py


示例14: test_info_recent

    def test_info_recent(self):
        """Test whether only packages in the repository are listed."""
        with mock.patch('time.time', return_value=0), \
                support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['recent'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                u'Recently Added Packages\n',
                self.HOLE_I686_INFO,
                self.HOLE_X86_64_INFO,
                self.PEPPER_UPDATES_INFO)))
开发者ID:auchytil,项目名称:dnf,代码行数:13,代码来源:test_commands.py


示例15: test_info_installed

    def test_info_installed(self):
        """Test whether only packages installed from the repository are listed."""
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed().filter(name='pepper'):
            mockSwdbPkg(history, pkg, repo='main')

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['main', 'info', 'installed'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((self.INSTALLED_TITLE, self.PEPPER_SYSTEM_INFO)))
开发者ID:edynox,项目名称:dnf,代码行数:13,代码来源:test_commands.py


示例16: test_rpm_logging

 def test_rpm_logging(self):
     # log everything to the console:
     self.logging.setup(dnf.logging.SUBDEBUG, dnf.logging.SUBDEBUG,
                       self.logdir)
     logger = logging.getLogger("dnf.rpm")
     with support.patch_std_streams() as (stdout, stderr):
         logger.info('rpm transaction happens.')
     # rpm logger never outputs to the console:
     self.assertEqual(stdout.getvalue(), "")
     self.assertEqual(stderr.getvalue(), "")
     logfile = os.path.join(self.logdir, "dnf.rpm.log")
     self.assertFile(logfile)
     with open(logfile) as f:
         msgs =  map(operator.attrgetter("message"),
                     map(_split_logfile_entry, f.readlines()))
     self.assertSequenceEqual(msgs, [dnf.const.LOG_MARKER,
                                     'rpm transaction happens.'])
开发者ID:PaulReiber,项目名称:dnf,代码行数:17,代码来源:test_logging.py


示例17: test_file_logging

 def test_file_logging(self):
     # log nothing to the console:
     self.logging.setup(dnf.logging.SUPERCRITICAL, dnf.logging.SUPERCRITICAL,
                       self.logdir)
     logger = logging.getLogger("dnf")
     with support.patch_std_streams() as (stdout, stderr):
         logger.info("i")
         logger.critical("c")
     self.assertEqual(stdout.getvalue(), '')
     self.assertEqual(stderr.getvalue(), '')
     # yet the file should contain both the entries:
     logfile = os.path.join(self.logdir, "dnf.log")
     self.assertFile(logfile)
     with open(logfile) as f:
         msgs =  map(operator.attrgetter("message"),
                     map(_split_logfile_entry, f.readlines()))
     self.assertSequenceEqual(msgs, [dnf.const.LOG_MARKER, 'i', 'c'])
开发者ID:PaulReiber,项目名称:dnf,代码行数:17,代码来源:test_logging.py


示例18: test_info_upgrades

    def test_info_upgrades(self):
        """Test whether only upgrades in the repository are listed."""
        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['upgrades'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                u'Upgraded Packages\n'
                u'Name        : hole\n'
                u'Arch        : x86_64\n'
                u'Epoch       : 0\n'
                u'Version     : 1\n'
                u'Release     : 2\n'
                u'Size        : 0.0  \n'
                u'Repo        : updates\n'
                u'Summary     : \n'
                u'License     : None\n'
                u'Description : \n'
                u'\n',
                self.HOLE_X86_64_INFO,
                self.PEPPER_UPDATES_INFO)))
开发者ID:auchytil,项目名称:dnf,代码行数:22,代码来源:test_commands.py


示例19: test_info_all

    def test_info_all(self):
        """Test whether only packages related to the repository are listed."""
        for pkg in self.cli.base.sack.query().installed().filter(name='pepper'):
            self.cli.base._yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.cli.base._yumdb.get_package(pkg).from_repo = 'main'

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['main', 'info', 'all', '*p*'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                self.INSTALLED_TITLE,
                self.PEPPER_SYSTEM_INFO,
                self.AVAILABLE_TITLE,
                u'Name         : pepper\n'
                u'Version      : 20\n'
                u'Release      : 0\n'
                u'Arch         : src\n'
                u'Size         : 0.0  \n'
                u'Source       : None\n'
                u'Repo         : main\n'
                u'Summary      : \n'
                u'License      : \n'
                u'Description  : \n'
                u'\n',
                u'Name         : trampoline\n'
                u'Version      : 2.1\n'
                u'Release      : 1\n'
                u'Arch         : noarch\n'
                u'Size         : 0.0  \n'
                u'Source       : None\n'
                u'Repo         : main\n'
                u'Summary      : \n'
                u'License      : \n'
                u'Description  : \n'
                u'\n')))
开发者ID:Conan-Kudo,项目名称:dnf,代码行数:38,代码来源:test_commands.py


示例20: test_info_extras

    def test_info_extras(self):
        """Test whether only extras installed from the repository are listed."""
        for pkg in self._cmd.base.sack.query().installed().filter(name='tour'):
            self._cmd.base.yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self._cmd.base.yumdb.get_package(pkg).from_repo = 'unknown'

        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('unknown', ['extras'])

        self.assertEqual(
            stdout.getvalue(),
            u'Extra Packages\n'
            u'Name        : tour\n'
            u'Arch        : noarch\n'
            u'Epoch       : 0\n'
            u'Version     : 5\n'
            u'Release     : 0\n'
            u'Size        : 0.0  \n'
            u'Repo        : @System\n'
            u'From repo   : unknown\n'
            u'Summary     : \n'
            u'License     : None\n'
            u'Description : \n\n')
开发者ID:auchytil,项目名称:dnf,代码行数:23,代码来源:test_commands.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python support.wiretap_logs函数代码示例发布时间:2022-05-27
下一篇:
Python support.mock_sack函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap