tests/test_prettysize.py
changeset 83 515fadd3d286
parent 82 7b82dc1fb6f5
child 84 3b5dd9efba35
equal deleted inserted replaced
82:7b82dc1fb6f5 83:515fadd3d286
     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