本文整理汇总了Python中test.helper.capture_stdout函数的典型用法代码示例。如果您正苦于以下问题:Python capture_stdout函数的具体用法?Python capture_stdout怎么用?Python capture_stdout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了capture_stdout函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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))
示例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())
示例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())
示例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())
示例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(), '')
示例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)
示例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')
示例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())
示例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())
示例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())
示例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)
示例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')
示例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')
示例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())