本文整理汇总了Python中vcs.utils.progressbar.ProgressBar.stream方法的典型用法代码示例。如果您正苦于以下问题:Python ProgressBar.stream方法的具体用法?Python ProgressBar.stream怎么用?Python ProgressBar.stream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcs.utils.progressbar.ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.stream方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_change_stream
# 需要导入模块: from vcs.utils.progressbar import ProgressBar [as 别名]
# 或者: from vcs.utils.progressbar.ProgressBar import stream [as 别名]
def test_change_stream(self):
stream1 = StringIO()
stream2 = StringIO()
bar = ProgressBar()
bar.stream = stream1
bar.write('foo')
bar.stream = stream2
bar.write('bar')
self.assertEquals(stream2.getvalue(), 'bar')
示例2: test_iter_ends_at_last_step
# 需要导入模块: from vcs.utils.progressbar import ProgressBar [as 别名]
# 或者: from vcs.utils.progressbar.ProgressBar import stream [as 别名]
def test_iter_ends_at_last_step(self):
bar = ProgressBar()
bar.stream = StringIO()
bar.steps = 20
bar.step = 5
stepped = list(bar)
self.assertEquals(stepped[-1], 20)
示例3: test_iter_starts_from_current_step
# 需要导入模块: from vcs.utils.progressbar import ProgressBar [as 别名]
# 或者: from vcs.utils.progressbar.ProgressBar import stream [as 别名]
def test_iter_starts_from_current_step(self):
bar = ProgressBar()
bar.stream = StringIO()
bar.steps = 20
bar.step = 5
stepped = list(bar)
self.assertEquals(stepped[0], 5)
示例4: test_render_raises_error_if_bar_already_finished
# 需要导入模块: from vcs.utils.progressbar import ProgressBar [as 别名]
# 或者: from vcs.utils.progressbar.ProgressBar import stream [as 别名]
def test_render_raises_error_if_bar_already_finished(self):
bar = ProgressBar(10)
bar.stream = StringIO()
bar.render(10)
with self.assertRaises(AlreadyFinishedError):
bar.render(0)
示例5: test_render_writes_new_line_at_last_step
# 需要导入模块: from vcs.utils.progressbar import ProgressBar [as 别名]
# 或者: from vcs.utils.progressbar.ProgressBar import stream [as 别名]
def test_render_writes_new_line_at_last_step(self):
from StringIO import StringIO
bar = ProgressBar()
bar.stream = StringIO()
bar.steps = 5
bar.render(5)
self.assertEquals(bar.stream.getvalue()[-1], '\n')
示例6: test_write
# 需要导入模块: from vcs.utils.progressbar import ProgressBar [as 别名]
# 或者: from vcs.utils.progressbar.ProgressBar import stream [as 别名]
def test_write(self):
from StringIO import StringIO
stream = StringIO()
bar = ProgressBar()
bar.stream = stream
bar.write('foobar')
self.assertEquals(stream.getvalue(), 'foobar')
示例7: test_get_eta
# 需要导入模块: from vcs.utils.progressbar import ProgressBar [as 别名]
# 或者: from vcs.utils.progressbar.ProgressBar import stream [as 别名]
def test_get_eta(self):
bar = ProgressBar(100)
bar.stream = StringIO()
bar.render(50)
now = datetime.datetime.now()
delta = now - bar.started
self.assertEquals(get_total_seconds(bar.get_eta(now)),
int(get_total_seconds(delta) * 0.5))
bar.render(75)
now = datetime.datetime.now()
delta = now - bar.started
self.assertEquals(get_total_seconds(bar.get_eta(now)),
int(get_total_seconds(delta) * 0.25))