示例#1
0
    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))
    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))
示例#3
0
 def get_eta(self, current_time=None):
     if current_time is None:
         current_time = datetime.datetime.now()
     if self.step == 0:
         return datetime.timedelta()
     total_seconds = get_total_seconds(self.get_total_time())
     eta_seconds = total_seconds * self.steps / self.step - total_seconds
     return datetime.timedelta(seconds=int(eta_seconds))
示例#4
0
 def get_eta(self, current_time=None):
     if current_time is None:
         current_time = datetime.datetime.now()
     if self.step == 0:
         return datetime.timedelta()
     total_seconds = get_total_seconds(self.get_total_time())
     eta_seconds = total_seconds * self.steps / self.step - total_seconds
     return datetime.timedelta(seconds=int(eta_seconds))
示例#5
0
 def get_rendered_speed(self, step=None, total_seconds=None):
     if step is None:
         step = self.step
     if total_seconds is None:
         total_seconds = get_total_seconds(self.get_total_time())
     if step <= 0 or total_seconds <= 0:
         speed = "-"
     else:
         speed = filesizeformat(float(step) / total_seconds)
     return "%s: %s/s" % (self.speed_label, speed)
示例#6
0
 def get_rendered_speed(self, step=None, total_seconds=None):
     if step is None:
         step = self.step
     if total_seconds is None:
         total_seconds = get_total_seconds(self.get_total_time())
     if step <= 0 or total_seconds <= 0:
         speed = '-'
     else:
         speed = filesizeformat(float(step) / total_seconds)
     return '%s: %s/s' % (self.speed_label, speed)
示例#7
0
 def assertTotalSecondsEqual(self, timedelta, expected_seconds):
     result = get_total_seconds(timedelta)
     self.assertEqual(
         result, expected_seconds,
         "We computed %s seconds for %s but expected %s" %
         (result, timedelta, expected_seconds))
示例#8
0
文件: test_utils.py 项目: methane/vcs
 def assertTotalSecondsEqual(self, timedelta, expected_seconds):
     result = get_total_seconds(timedelta)
     self.assertEqual(result, expected_seconds,
         "We computed %s seconds for %s but expected %s"
         % (result, timedelta, expected_seconds))