def get_rendered_transfer(self, step=None, steps=None): if step is None: step = self.step if steps is None: steps = self.steps if steps <= 0: return '%s: -' % self.transfer_label total = filesizeformat(float(steps)) if step <= 0: transferred = '-' else: transferred = filesizeformat(float(step)) return '%s: %s / %s' % (self.transfer_label, transferred, total)
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)
def get_rendered_speed(self, step=None, total_seconds=None): if step is None: step = self.step if total_seconds is None: total_seconds = self.get_total_time().total_seconds() if step <= 0 or total_seconds <= 0: speed = '-' else: speed = filesizeformat(float(step) / total_seconds) return '%s: %s/s' % (self.speed_label, speed)
def test_kilobytes(self): self.assertEqual(filesizeformat(1024 * 2), '2 KB')
def test_kilobytes(self): assert filesizeformat(1024 * 2) == '2 KB'
def test_bytes(self): assert filesizeformat(10) == '10 B'
def test_that_function_respects_sep_parameter(self): assert filesizeformat(1, '') == '1B'
def test_gigabytes(self): assert filesizeformat(1024 * 1024 * 1024 * 12.92) == '12.92 GB'
def test_megabytes(self): self.assertEqual(filesizeformat(1024 * 1024 * 2.3), '2.3 MB')
def test_that_function_respects_sep_paramtere(self): self.assertEqual(filesizeformat(1, ''), '1B')
def test_bytes(self): self.assertEqual(filesizeformat(10), '10 B')
def test_gigabytes(self): self.assertEqual(filesizeformat(1024 * 1024 * 1024 * 12.92), '12.92 GB')
def test_megabytes(self): assert filesizeformat(1024 * 1024 * 2.3) == '2.3 MB'