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


Python support.patch_std_streams函数代码示例

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


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


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