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

Python helper.capture_stdout函数代码示例

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

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



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

示例1: test_show_user_config_with_defaults

 def test_show_user_config_with_defaults(self):
     with capture_stdout() as output:
         self.run_command('config', '-d')
     output = yaml.load(output.getvalue())
     self.assertEqual(output['option'], 'value')
     self.assertEqual(output['library'], 'lib')
     self.assertEqual(output['import']['timid'], False)
开发者ID:scztt,项目名称:beets,代码行数:7,代码来源:test_config_command.py


示例2: test_list_unicode_query

    def test_list_unicode_query(self):
        self.item.title = u'na\xefve'
        self.item.store()
        self.lib._connection().commit()

        with capture_stdout() as stdout:
            self._run_list([u'na\xefve'])
        out = stdout.getvalue()
        self.assertTrue(u'na\xefve' in out.decode(stdout.encoding))
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:9,代码来源:test_ui.py


示例3: test_write_metadata_field

    def test_write_metadata_field(self):
        item = self.add_item_fixture()
        item.read()
        old_title = item.title

        item.title = "new title"
        item.store()

        with capture_stdout() as stdout:
            self.write_cmd()

        self.assertTrue("{0} -> new title".format(old_title) in stdout.getvalue())
开发者ID:glamglim,项目名称:beets,代码行数:12,代码来源:test_ui.py


示例4: test_print_tracks_output_as_tracks

    def test_print_tracks_output_as_tracks(self):
        """Test the output of the "print tracks" choice, as singletons."""
        self.matcher.matching = AutotagStub.BAD

        with capture_stdout() as output:
            with control_stdin("\n".join(["t", "s", "p", "s"])):
                # as Tracks; Skip; Print tracks; Skip
                self.importer.run()

        # Manually build the string for comparing the output.
        tracklist = u"Print tracks? " u"02. Tag Title 2 - Tag Artist (0:01)"
        self.assertIn(tracklist, output.getvalue())
开发者ID:angelsanz,项目名称:beets,代码行数:12,代码来源:test_mbsubmit.py


示例5: test_print_tracks_output

    def test_print_tracks_output(self):
        """Test the output of the "print tracks" choice."""
        self.matcher.matching = AutotagStub.BAD

        with capture_stdout() as output:
            with control_stdin('\n'.join(['p', 's'])):
                # Print tracks; Skip
                self.importer.run()

        # Manually build the string for comparing the output.
        tracklist = ('Print tracks? '
                     '01. Tag Title 1 - Tag Artist (0:01)\n'
                     '02. Tag Title 2 - Tag Artist (0:01)')
        self.assertIn(tracklist, output.getvalue())
开发者ID:ali-graham,项目名称:beets,代码行数:14,代码来源:test_mbsubmit.py


示例6: test_non_metadata_field_unchanged

    def test_non_metadata_field_unchanged(self):
        """Changing a non-"tag" field like `bitrate` and writing should
        have no effect.
        """
        # An item that starts out "clean".
        item = self.add_item_fixture()
        item.read()

        # ... but with a mismatched bitrate.
        item.bitrate = 123
        item.store()

        with capture_stdout() as stdout:
            self.write_cmd()

        self.assertEqual(stdout.getvalue(), '')
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:16,代码来源:test_ui.py


示例7: test_list_album_outputs_something

 def test_list_album_outputs_something(self):
     with capture_stdout() as stdout:
         self._run_list(album=True)
     self.assertGreater(len(stdout.getvalue()), 0)
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:4,代码来源:test_ui.py


示例8: test_list_item_path

 def test_list_item_path(self):
     with capture_stdout() as stdout:
         self._run_list(fmt=u'$path')
     self.assertEqual(stdout.getvalue().strip(), u'xxx/yyy')
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:4,代码来源:test_ui.py


示例9: test_list_outputs_item

 def test_list_outputs_item(self):
     with capture_stdout() as stdout:
         self._run_list()
     self.assertIn(u'the title', stdout.getvalue())
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:4,代码来源:test_ui.py


示例10: test_list_album_uses_album_artist

 def test_list_album_uses_album_artist(self):
     with capture_stdout() as stdout:
         self._run_list(album=True)
     self.assertNotIn(u'the artist', stdout.getvalue())
     self.assertIn(u'the album artist', stdout.getvalue())
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:5,代码来源:test_ui.py


示例11: test_list_item_format_artist

 def test_list_item_format_artist(self):
     with capture_stdout() as stdout:
         self._run_list(fmt=u'$artist')
     self.assertIn(u'the artist', stdout.getvalue())
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:4,代码来源:test_ui.py


示例12: test_config_paths_with_cli

 def test_config_paths_with_cli(self):
     with capture_stdout() as output:
         self.run_command('--config', self.cli_config_path, 'config', '-p')
     paths = output.getvalue().split('\n')
     self.assertEqual(len(paths), 3)
     self.assertEqual(paths[0], self.cli_config_path)
开发者ID:scztt,项目名称:beets,代码行数:6,代码来源:test_config_command.py


示例13: test_show_user_config_with_cli

 def test_show_user_config_with_cli(self):
     with capture_stdout() as output:
         self.run_command('--config', self.cli_config_path, 'config')
     output = yaml.load(output.getvalue())
     self.assertEqual(output['library'], 'lib')
     self.assertEqual(output['option'], 'cli overwrite')
开发者ID:scztt,项目名称:beets,代码行数:6,代码来源:test_config_command.py


示例14: test_show_user_config

 def test_show_user_config(self):
     with capture_stdout() as output:
         self.run_command('config')
     output = yaml.load(output.getvalue())
     self.assertEqual(output['option'], 'value')
开发者ID:scztt,项目名称:beets,代码行数:5,代码来源:test_config_command.py


示例15: test_list_uses_track_artist

 def test_list_uses_track_artist(self):
     with capture_stdout() as stdout:
         self._run_list()
     self.assertIn("the artist", stdout.getvalue())
     self.assertNotIn("the album artist", stdout.getvalue())
开发者ID:glamglim,项目名称:beets,代码行数:5,代码来源:test_ui.py


示例16: test_list_album_path

 def test_list_album_path(self):
     with capture_stdout() as stdout:
         self._run_list(album=True, fmt=u'$path')
     self.assertEqual(stdout.getvalue().strip(), u'xxx')
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:4,代码来源:test_ui.py


示例17: test_list_album_omits_title

 def test_list_album_omits_title(self):
     with capture_stdout() as stdout:
         self._run_list(album=True)
     self.assertNotIn(u'the title', stdout.getvalue())
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:4,代码来源:test_ui.py


示例18: test_list_item_format_multiple

 def test_list_item_format_multiple(self):
     with capture_stdout() as stdout:
         self._run_list(fmt=u'$artist - $album - $year')
     self.assertEqual(u'the artist - the album - 0001',
                      stdout.getvalue().strip())
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:5,代码来源:test_ui.py


示例19: _run_list

 def _run_list(self, query=u'', album=False, path=False, fmt=u''):
     with capture_stdout() as stdout:
         commands.list_items(self.lib, query, album, fmt)
     return stdout
开发者ID:shamangeorge,项目名称:beets,代码行数:4,代码来源:test_ui.py


示例20: test_list_album_format

 def test_list_album_format(self):
     with capture_stdout() as stdout:
         self._run_list(album=True, fmt=u'$genre')
     self.assertIn(u'the genre', stdout.getvalue())
     self.assertNotIn(u'the album', stdout.getvalue())
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:5,代码来源:test_ui.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python helper.control_stdin函数代码示例发布时间:2022-05-27
下一篇:
Python helper.capture_log函数代码示例发布时间: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