tests/testprettysize.py
changeset 2 efee419b7a2d
child 10 f3a1b9792cc9
equal deleted inserted replaced
0:eaae9539e910 2:efee419b7a2d
       
     1 #!/usr/bin/env python3
       
     2 
       
     3 import unittest
       
     4 import prettysize
       
     5 
       
     6 class TestHumansize(unittest.TestCase):
       
     7     def test_humansize(self):
       
     8         psize = prettysize.prettysize_short
       
     9         expected = (
       
    10             (0, '0'),
       
    11             (1000, '1000'),
       
    12             (1024, '1K'),
       
    13             (1050, '1.03K'),
       
    14             (2050, '2K'),
       
    15             (333333, '325.52K'),
       
    16             (1048576, '1M'),
       
    17             (1050000, '1M'),
       
    18             (5555555, '5.3M'),
       
    19             (1073741824, '1G'),
       
    20             )
       
    21         for input, result in expected:
       
    22             self.assertEqual(psize(input), result)
       
    23 
       
    24 
       
    25 if __name__ == '__main__':
       
    26     unittest.main()