/usr/lib/python3/dist-packages/checkbox_support/tests/test_human_readable_bytes.py is in python3-checkbox-support 0.22-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # This file is part of Checkbox.
#
# Copyright 2014 Canonical Ltd.
# Written by:
# Maciej Kisielewski <maciej.kisielewski@canonical.com>
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.
#
# Checkbox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
"""
checkbox_support.tests.test_human_readable_bytes
================================================
Tests for checkbox_support.helpers.human_readable_bytes module
"""
import unittest
from checkbox_support.helpers.human_readable_bytes import HumanReadableBytes
class HumanReadableBytesTests(unittest.TestCase):
"""
Tests for HumanReadableBytesTests class
"""
def test_parsing_all_equal_four(self):
fours = [HumanReadableBytes(4), 4, HumanReadableBytes("4"),
HumanReadableBytes("4B"), HumanReadableBytes("4b"), int("4")]
self.assertEqual(all(fours[0] == four for four in fours), True)
def test_parsin_all_minus_2kibi(self):
values = [HumanReadableBytes("-2ki"), -2048,
HumanReadableBytes("-2048"), HumanReadableBytes("-2KiB")]
self.assertEqual(all(values[0] == val for val in values), True)
def test_four_megs(self):
values = [HumanReadableBytes("4mB"), int("4"+"0"*6),
HumanReadableBytes(4000000), 4000000]
self.assertEqual(all(values[0] == val for val in values), True)
def test_str(self):
self.assertEqual(str(HumanReadableBytes("4mi")), "4MiB")
def test_str_rounding(self):
self.assertEqual(str(HumanReadableBytes(4*1024*1024+1)), "4.00MiB")
def test_str_zero(self):
self.assertEqual(str(HumanReadableBytes("0 MiB")), "0B")
def test_repr(self):
self.assertEqual(repr(HumanReadableBytes("5kib")),
"HumanReadableBytes(5120)")
|