<commit_before># pylint: disable=C0103,C0111

import unittest
import re

import tests.mocks as mocks

import bumblebee.util as bu


class TestUtil(unittest.TestCase):
    def setUp(self):
        self.popen = mocks.MockPopen("bumblebee.util")
        self.some_command_with_args = "sample-command -a -b -c"
        self.some_utf8 = "some string".encode("utf-8")

    def tearDown(self):
        self.popen.cleanup()

    def test_bytefmt(self):
        self.assertEquals(bu.bytefmt(10), "10.00B")
        self.assertEquals(bu.bytefmt(15 * 1024), "15.00KiB")
        self.assertEquals(bu.bytefmt(20 * 1024 * 1024), "20.00MiB")
        self.assertEquals(bu.bytefmt(22 * 1024 * 1024 * 1024), "22.00GiB")
        self.assertEquals(bu.bytefmt(35 * 1024 * 1024 * 1024 * 1024), "35840.00GiB")

    def test_durationfmt(self):
        self.assertEquals(bu.durationfmt(00), "00:00")
        self.assertEquals(bu.durationfmt(25), "00:25")
        self.assertEquals(bu.durationfmt(60), "01:00")
        self.assertEquals(bu.durationfmt(119), "01:59")
        self.assertEquals(bu.durationfmt(3600), "01:00:00")
        self.assertEquals(bu.durationfmt(7265), "02:01:05")

    def test_execute(self):
        bu.execute(self.some_command_with_args)
        self.assertTrue(self.popen.mock.popen.called)
        self.popen.mock.popen.assert_call(self.some_command_with_args)
        self.assertTrue(self.popen.mock.communicate.called)

    def test_execute_nowait(self):<commit_msg>add tests with custom format for bumblebee.util.bytefmt()<commit_after># pylint: disable=C0103,C0111

import unittest
import re

import tests.mocks as mocks

import bumblebee.util as bu


class TestUtil(unittest.TestCase):
    def setUp(self):
        self.popen = mocks.MockPopen("bumblebee.util")
        self.some_command_with_args = "sample-command -a -b -c"
        self.some_utf8 = "some string".encode("utf-8")

    def tearDown(self):
        self.popen.cleanup()

    def test_bytefmt(self):
        self.assertEquals(bu.bytefmt(10), "10.00B")
        self.assertEquals(bu.bytefmt(15 * 1024), "15.00KiB")
        self.assertEquals(bu.bytefmt(20 * 1024 * 1024), "20.00MiB")
        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")
        self.assertEquals(bu.durationfmt(60), "01:00")
        self.assertEquals(bu.durationfmt(119), "01:59")
        self.assertEquals(bu.durationfmt(3600), "01:00:00")
        self.assertEquals(bu.durationfmt(7265), "02:01:05")

    def test_execute(self):
        bu.execute(self.some_command_with_args)
        self.assertTrue(self.popen.mock.popen.called)
        self.popen.mock.popen.assert_call(self.some_command_with_args)
        self.assertTrue(self.popen.mock.communicate.called)

    def test_execute_nowait(self):
{'fraction_non_alphanumeric': 0.14507000297885017, 'fraction_numerical': 0.0953232052427763, 'mean_word_length': 3.3329032258064517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6674856', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1147, 'n_words': 184}