tests/testprettysize.py
changeset 50 f71d3abbb18f
parent 49 08e4dfe1b0cb
child 51 bdc44f96cb0b
equal deleted inserted replaced
49:08e4dfe1b0cb 50:f71d3abbb18f
     1 #!/usr/bin/env python3
       
     2 
       
     3 import unittest
       
     4 from pgtoolkit 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()