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