示例#1
0
 def test_bytes_to_humand_readable_exact_conversion(self):
     try:
         bt = bytes_to_human_readable(12288)
         self.assertEqual('12.0 kb', bt, msg='12288 b should have been 12.0 kb')
         bt = bytes_to_human_readable(3300000)
         self.assertEqual('3.1 mb', bt, msg='3300000 b should have been 3.1 mb')
         bt = bytes_to_human_readable(13000000000)
         self.assertEqual('12.1 gb', bt, msg='13000000000 b should have been 12.1 gb')
         bt = bytes_to_human_readable(24500000000000)
         self.assertEqual('22.3 tb', bt, msg='24500000000000 b should have been 22.3 tb')
     except Exception as e:
         self.fail(f"Exception occured when tried to convert bytes to human readable format {e}")
示例#2
0
 def test_bytes_to_human_readable_zero_input(self):
     try:
         bt = bytes_to_human_readable(0)
         self.assertEqual('0.0 B', bt)
     except Exception as e:
         self.fail(
             f"Exception occured when None value was given as an argument {e}"
         )
示例#3
0
 def test_bytes_to_human_readable_convert_to_gb(self):
     try:
         for i in range(20):
             bt = random.randint(1073741824, 549755813888)
             human = bytes_to_human_readable(bt).split(' ')[1]
             self.assertEqual(human, 'gb', msg='Should be gb')
     except Exception as e:
         self.fail(f"Exception occured when gb range values were given as an argument {e}")
示例#4
0
 def test_bytes_to_human_readable_convert_to_mb(self):
     try:
         for i in range(20):
             bt = random.randint(1048576, 943718400)
             human = bytes_to_human_readable(bt).split(' ')[1]
             self.assertEqual(human, 'mb', msg='Should be mb')
     except Exception as e:
         self.fail(f"Exception occured when mb range values were given as an argument {e}")