<commit_before>"""
@brief      test log(time=1s)
"""


import sys
import os
import unittest


try:
    import src
except ImportError:
    path = os.path.normpath(
        os.path.abspath(
            os.path.join(
                os.path.split(__file__)[0],
                "..",
                "..")))
    if path not in sys.path:
        sys.path.append(path)
    import src

from src.pyquickhelper.loghelper.flog import fLOG
from src.pyquickhelper.loghelper import run_cmd, reap_children, CustomLog
from src.pyquickhelper.pycode import get_temp_folder


class TestProcessHelper(unittest.TestCase):

    def test_reap_children(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        if sys.platform.startswith("win"):
            cmd = "more"
        else:
            cmd = 'ls -la | less'
        temp = get_temp_folder(__file__, "temp_nb_bug_rst")
        clog = CustomLog(temp)
        proc, _ = run_cmd(cmd, wait=False, fLOG=clog)
        self.assertTrue(_ is None)
        ki = reap_children(fLOG=clog, subset={proc.pid})
        clog('ki={0}'.format(ki))
        self.assertTrue(ki is not None)
        self.assertEqual(len(ki), 1)
        # fLOG(ki)
        # To avoid a warning.
        proc.returncode = 0


if __name__ == "__main__":
    unittest.main()<commit_msg>better display in unit test<commit_after>"""
@brief      test log(time=1s)
"""


import sys
import os
import unittest


try:
    import src
except ImportError:
    path = os.path.normpath(
        os.path.abspath(
            os.path.join(
                os.path.split(__file__)[0],
                "..",
                "..")))
    if path not in sys.path:
        sys.path.append(path)
    import src

from src.pyquickhelper.loghelper.flog import fLOG
from src.pyquickhelper.loghelper import run_cmd, reap_children, CustomLog
from src.pyquickhelper.pycode import get_temp_folder


class TestProcessHelper(unittest.TestCase):

    def test_reap_children(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        if sys.platform.startswith("win"):
            cmd = "pause"
        else:
            cmd = 'ls -la | less'
        temp = get_temp_folder(__file__, "temp_reap_children")
        clog = CustomLog(temp)
        proc, _ = run_cmd(cmd, wait=False, fLOG=clog)
        self.assertTrue(_ is None)
        clog('proc={} pid={}'.format(proc, proc.pid))
        ki = reap_children(fLOG=clog, subset={proc.pid})
        clog('ki={0}'.format(ki))
        self.assertTrue(ki is not None)
        self.assertEqual(len(ki), 1)
        # fLOG(ki)
        # To avoid a warning.
        proc.returncode = 0


if __name__ == "__main__":
    unittest.main()
{'fraction_non_alphanumeric': 0.11665470208183776, 'fraction_numerical': 0.003589375448671931, 'mean_word_length': 2.1598639455782314, 'pattern_counts': {'":': 2, '<': 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': '4144288', 'n_tokens_mistral': 910, 'n_tokens_neox': 891, 'n_words': 192}