From c518f34e2e6300178a93c801f59413473748adb9 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 22 Nov 2010 20:22:35 +0100 Subject: ext.human_readable: added doctest --- ranger/ext/human_readable.py | 10 +++++++--- 1 file 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() -- cgit 1.4.1-2-gfad0