def test_calc_unit_raises_value_error(self): self.assertRaises(ValueError, bytes2human.calc_unit, 1, None) self.assertRaises(ValueError, bytes2human.calc_unit, 1, 100) self.assertRaises(ValueError, bytes2human.calc_unit, 1, 999) self.assertRaises(ValueError, bytes2human.calc_unit, 1, 1023) self.assertRaises(ValueError, bytes2human.calc_unit, 1, 1025) self.assertEqual((1.0, 'B'), bytes2human.calc_unit(1, 1024)) self.assertEqual((1.0, 'B'), bytes2human.calc_unit(1, 1000))
def test_calc_unit(self): self.assertEqual(bytes2human.calc_unit(12456, 1024), (12.1640625, 'KiB')) self.assertEqual(bytes2human.calc_unit(-12456, 1000), (-12.456, 'kB')) self.assertRaises(ValueError, bytes2human.calc_unit, 0, 1001)