mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-23 01:37:47 +00:00
Increased test coverage of format tests
This commit is contained in:
@@ -45,6 +45,15 @@ class Testbytes2human(PicardTestCase):
|
||||
except Exception as e:
|
||||
self.fail('Unexpected exception: %s' % e)
|
||||
|
||||
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.assertEquals((1.0, 'B'), bytes2human.calc_unit(1, 1024))
|
||||
self.assertEquals((1.0, 'B'), bytes2human.calc_unit(1, 1000))
|
||||
|
||||
def run_test(self, lang='C', create_test_data=False):
|
||||
"""
|
||||
Compare data generated with sample files
|
||||
@@ -70,12 +79,12 @@ class Testbytes2human(PicardTestCase):
|
||||
p *= n
|
||||
for x in [0.1, 0.5, 0.99, 0.9999, 1, 1.5]:
|
||||
values.append(int(p * x))
|
||||
l = []
|
||||
list = []
|
||||
for x in sorted(values):
|
||||
l.append(";".join([str(x), bytes2human.decimal(x),
|
||||
bytes2human.binary(x),
|
||||
bytes2human.short_string(x, 1024, 2)]))
|
||||
return l
|
||||
list.append(";".join([str(x), bytes2human.decimal(x),
|
||||
bytes2human.binary(x),
|
||||
bytes2human.short_string(x, 1024, 2)]))
|
||||
return list
|
||||
|
||||
def _save_expected_to(self, path, a_list):
|
||||
with open(path, 'wb') as f:
|
||||
|
||||
Reference in New Issue
Block a user