import subprocess
import sys

from unittest import TestCase

from abl.webconnector.util import check_exe_running


class UtilTests(TestCase):
    def test_check_exe_running(self):
        assert check_exe_running(sys.executable)

        if sys.platform == "darwin":
            cmd = ["/bin/sleep", "1"]
            assert not check_exe_running(cmd[0])
            p = subprocess.Popen(cmd)
            assert check_exe_running(cmd[0])
            p.wait()
