author | Radek Brich <radek.brich@devl.cz> |
Tue, 26 Feb 2013 14:40:39 +0100 | |
changeset 68 | b0d972be2631 |
parent 50 | f71d3abbb18f |
permissions | -rw-r--r-- |
2 | 1 |
#!/usr/bin/env python3 |
2 |
||
50
f71d3abbb18f
Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
3 |
from pgtoolkit import prettysize |
f71d3abbb18f
Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
4 |
|
2 | 5 |
import unittest |
50
f71d3abbb18f
Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
6 |
|
2 | 7 |
|
50
f71d3abbb18f
Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
8 |
class TestPrettySize(unittest.TestCase): |
f71d3abbb18f
Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
9 |
def test_prettysize(self): |
2 | 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() |
|
50
f71d3abbb18f
Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
29 |