"""
@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


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'
        proc, _ = run_cmd(cmd, wait=False, fLOG=fLOG)
        self.assertTrue(_ is None)
        ki = reap_children(fLOG=fLOG, subset={proc.pid})
        self.assertEqual(len(ki), 1)
        # fLOG(ki)
        # To avoid a warning.
        proc.returncode = 0


if __name__ == "__main__":
    unittest.main()

@@ -469,16 +469,80 @@
 children
+, CustomLog%0Afrom src.pyquickhelper.pycode import get_temp_folder
 %0A%0A%0Aclass
@@ -850,16 +850,107 @@
 %7C less'%0A
+        temp = get_temp_folder(__file__, %22temp_nb_bug_rst%22)%0A        clog = CustomLog(temp)%0A
         
@@ -989,20 +989,20 @@
 e, fLOG=
-fLOG
+clog
 )%0A      
@@ -1062,20 +1062,20 @@
 en(fLOG=
-fLOG
+clog
 , subset
@@ -1087,16 +1087,90 @@
 c.pid%7D)%0A
+        clog('ki=%7B0%7D'.format(ki))%0A        self.assertTrue(ki is not None)%0A
         

update unit test