From d952661b282082583a8155b105d8dd059141f108 Mon Sep 17 00:00:00 2001 From: me Date: Sun, 12 Jan 2020 20:33:51 +0200 Subject: [PATCH] add tests with custom format for bumblebee.util.bytefmt() --- tests/test_util.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_util.py b/tests/test_util.py index 828728b..1a7ee07 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -24,6 +24,13 @@ class TestUtil(unittest.TestCase): self.assertEquals(bu.bytefmt(22 * 1024 * 1024 * 1024), "22.00GiB") self.assertEquals(bu.bytefmt(35 * 1024 * 1024 * 1024 * 1024), "35840.00GiB") + fmt = "{:.0f}" + self.assertEquals(bu.bytefmt(10, fmt), "10B") + self.assertEquals(bu.bytefmt(15 * 1024, fmt), "15KiB") + self.assertEquals(bu.bytefmt(20 * 1024 * 1024, fmt), "20MiB") + self.assertEquals(bu.bytefmt(22 * 1024 * 1024 * 1024, fmt), "22GiB") + self.assertEquals(bu.bytefmt(35 * 1024 * 1024 * 1024 * 1024, fmt), "35840GiB") + def test_durationfmt(self): self.assertEquals(bu.durationfmt(00), "00:00") self.assertEquals(bu.durationfmt(25), "00:25")