diff options
author | hut <hut@lavabit.com> | 2010-11-22 20:22:35 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-11-22 20:22:35 +0100 |
commit | c518f34e2e6300178a93c801f59413473748adb9 (patch) | |
tree | a64423d7c9bac55414931ba1dbb644632b9869b3 | |
parent | cb41ff7ba0c1a60044bb4329812ceb9920965f03 (diff) | |
download | ranger-c518f34e2e6300178a93c801f59413473748adb9.tar.gz |
ext.human_readable: added doctest
-rw-r--r-- | ranger/ext/human_readable.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ranger/ext/human_readable.py b/ranger/ext/human_readable.py index 40111b6d..3ce6498a 100644 --- a/ranger/ext/human_readable.py +++ b/ranger/ext/human_readable.py @@ -18,11 +18,11 @@ def human_readable(byte, seperator=' '): Convert a large number of bytes to an easily readable format. >>> human_readable(54) - "54 B" + '54 B' >>> human_readable(1500) - "1.46 K" + '1.46 K' >>> human_readable(2 ** 20 * 1023) - "1023 M" + '1023 M' """ if byte <= 0: return '0' @@ -49,3 +49,7 @@ def human_readable(byte, seperator=' '): if byte < 2**60: return '%.4g%sP' % (byte / 2**50.0, seperator) return '>9000' + +if __name__ == '__main__': + import doctest + doctest.testmod() |