Example #1
0
def test_basic_info() -> None:
    proc = pypsutil.Process()

    assert proc.pid == os.getpid()
    assert proc.ppid() == os.getppid()
    assert proc.pgid() == os.getpgrp()
    assert proc.sid() == os.getsid(0)

    assert proc.status() == pypsutil.ProcessStatus.RUNNING

    assert proc.parent().pid == os.getppid()  # type: ignore

    assert proc.create_time() <= time.time()
    assert proc.create_time() >= pypsutil.boot_time()

    assert os.path.samefile(proc.cwd(), os.getcwd())
Example #2
0
def test_boot_time() -> None:
    assert pypsutil.boot_time() <= time.time()
Example #3
0
def test_time_since_boot() -> None:
    # Make sure they match up approximately
    assert round(
        time.time() - (pypsutil.boot_time() + pypsutil.time_since_boot()),
        1) == 0