# Path: vcs/utils/filesize.py
# def filesizeformat(bytes, sep=' '):
#     """
#     Formats the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB,
#     102 B, 2.3 GB etc).
# 
#     Grabbed from Django (http://www.djangoproject.com), slightly modified.
# 
#     :param bytes: size in bytes (as integer)
#     :param sep: string separator between number and abbreviation
#     """
#     try:
#         bytes = float(bytes)
#     except (TypeError, ValueError, UnicodeDecodeError):
#         return '0%sB' % sep
# 
#     if bytes < 1024:
#         size = bytes
#         template = '%.0f%sB'
#     elif bytes < 1024 * 1024:
#         size = bytes / 1024
#         template = '%.0f%sKB'
#     elif bytes < 1024 * 1024 * 1024:
#         size = bytes / 1024 / 1024
#         template = '%.1f%sMB'
#     else:
#         size = bytes / 1024 / 1024 / 1024
#         template = '%.2f%sGB'
#     return template % (size, sep)
# 
# Path: vcs/utils/compat.py
# class deque(object):
# class _Condition(_Verbose):
# class _Event(_Verbose):
#     def __init__(self, iterable=(), maxlen= -1):
#     def append(self, x):
#     def appendleft(self, x):
#     def pop(self):
#     def popleft(self):
#     def clear(self):
#     def extend(self, iterable):
#     def extendleft(self, iterable):
#     def rotate(self, n=1):
#     def __getitem__(self, i):
#     def __setitem__(self, i, value):
#     def __delitem__(self, i):
#     def __len__(self):
#     def __cmp__(self, other):
#     def __repr__(self, _track=[]):
#     def __getstate__(self):
#     def __setstate__(self, s):
#     def __hash__(self):
#     def __copy__(self):
#     def __deepcopy__(self, memo={}):
# def Condition(*args, **kwargs):
#     def __init__(self, lock=None, verbose=None):
#     def __enter__(self):
#     def __exit__(self, *args):
#     def __repr__(self):
#     def _release_save(self):
#     def _acquire_restore(self, x):
#     def _is_owned(self):
#     def wait(self, timeout=None):
#     def notify(self, n=1):
#     def notifyAll(self):
# def Event(*args, **kwargs):
#     def __init__(self, verbose=None):
#     def isSet(self):
#     def set(self):
#     def clear(self):
#     def wait(self, timeout=None):


from vcs.utils.filesize import filesizeformat
from vcs.utils.compat import unittest
from __future__ import with_statement



class TestFilesizeformat(unittest.TestCase):

    def test_bytes(self):
        self.assertEqual(filesizeformat(10), '10 B')

    def test_kilobytes(self):
        self.assertEqual(filesizeformat(1024 * 2), '2 KB')

    def test_megabytes(self):
        self.assertEqual(filesizeformat(1024 * 1024 * 2.3), '2.3 MB')

    def test_gigabytes(self):

# Path: vcs/utils/filesize.py
# def filesizeformat(bytes, sep=' '):
#     """
#     Formats the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB,
#     102 B, 2.3 GB etc).
# 
#     Grabbed from Django (http://www.djangoproject.com), slightly modified.
# 
#     :param bytes: size in bytes (as integer)
#     :param sep: string separator between number and abbreviation
#     """
#     try:
#         bytes = float(bytes)
#     except (TypeError, ValueError, UnicodeDecodeError):
#         return '0%sB' % sep
# 
#     if bytes < 1024:
#         size = bytes
#         template = '%.0f%sB'
#     elif bytes < 1024 * 1024:
#         size = bytes / 1024
#         template = '%.0f%sKB'
#     elif bytes < 1024 * 1024 * 1024:
#         size = bytes / 1024 / 1024
#         template = '%.1f%sMB'
#     else:
#         size = bytes / 1024 / 1024 / 1024
#         template = '%.2f%sGB'
#     return template % (size, sep)
# 
# Path: vcs/utils/compat.py
# class deque(object):
# class _Condition(_Verbose):
# class _Event(_Verbose):
#     def __init__(self, iterable=(), maxlen= -1):
#     def append(self, x):
#     def appendleft(self, x):
#     def pop(self):
#     def popleft(self):
#     def clear(self):
#     def extend(self, iterable):
#     def extendleft(self, iterable):
#     def rotate(self, n=1):
#     def __getitem__(self, i):
#     def __setitem__(self, i, value):
#     def __delitem__(self, i):
#     def __len__(self):
#     def __cmp__(self, other):
#     def __repr__(self, _track=[]):
#     def __getstate__(self):
#     def __setstate__(self, s):
#     def __hash__(self):
#     def __copy__(self):
#     def __deepcopy__(self, memo={}):
# def Condition(*args, **kwargs):
#     def __init__(self, lock=None, verbose=None):
#     def __enter__(self):
#     def __exit__(self, *args):
#     def __repr__(self):
#     def _release_save(self):
#     def _acquire_restore(self, x):
#     def _is_owned(self):
#     def wait(self, timeout=None):
#     def notify(self, n=1):
#     def notifyAll(self):
# def Event(*args, **kwargs):
#     def __init__(self, verbose=None):
#     def isSet(self):
#     def set(self):
#     def clear(self):
#     def wait(self, timeout=None):


# Path: vcs/tests/test_utils_filesize.py
from vcs.utils.filesize import filesizeformat
from vcs.utils.compat import unittest

from __future__ import with_statement



class TestFilesizeformat(unittest.TestCase):

    def test_bytes(self):
        self.assertEqual(filesizeformat(10), '10 B')

    def test_kilobytes(self):
        self.assertEqual(filesizeformat(1024 * 2), '2 KB')

    def test_megabytes(self):
        self.assertEqual(filesizeformat(1024 * 1024 * 2.3), '2.3 MB')

    def test_gigabytes(self):

        self.assertEqual(filesizeformat(1024 * 1024 * 1024 * 12.92), '12.92 GB')