author | Radek Brich <radek.brich@devl.cz> |
Sat, 29 Sep 2012 13:53:54 +0200 | |
changeset 49 | 08e4dfe1b0cb |
parent 10 | f3a1b9792cc9 |
permissions | -rwxr-xr-x |
2 | 1 |
#!/usr/bin/env python3 |
2 |
||
3 |
import unittest |
|
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
4 |
from pgtoolkit import prettysize |
2 | 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() |