diff options
| author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-04-25 18:32:00 +0200 |
|---|---|---|
| committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-04-25 18:32:00 +0200 |
| commit | 267de56fe0e424f86d3c615b2d770efefac2f35f (patch) | |
| tree | 3d8c283ac575fbe6d4041f4c6e8365cd602b1c24 /psutil/tests/test_misc.py | |
| parent | 9ad2d0f09d14af999ca0e31d3a4ed77fe41c5b81 (diff) | |
| download | psutil-267de56fe0e424f86d3c615b2d770efefac2f35f.tar.gz | |
add utility to create a child, grandchild process pair
Diffstat (limited to 'psutil/tests/test_misc.py')
| -rwxr-xr-x | psutil/tests/test_misc.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py index 35473692..13649755 100755 --- a/psutil/tests/test_misc.py +++ b/psutil/tests/test_misc.py @@ -30,6 +30,7 @@ from psutil._common import memoize_when_activated from psutil._common import supports_ipv6 from psutil.tests import APPVEYOR from psutil.tests import chdir +from psutil.tests import create_proc_children_pair from psutil.tests import get_test_subprocess from psutil.tests import importlib from psutil.tests import mock @@ -46,6 +47,7 @@ from psutil.tests import TRAVIS from psutil.tests import unittest from psutil.tests import wait_for_file from psutil.tests import wait_for_pid +import psutil.tests class TestMisc(unittest.TestCase): @@ -645,6 +647,24 @@ class TestTestUtils(unittest.TestCase): assert p.is_running() reap_children() assert not p.is_running() + assert not psutil.tests._pids_started + assert not psutil.tests._subprocesses_started + + def test_create_proc_children_pair(self): + p1, p2 = create_proc_children_pair() + self.assertNotEqual(p1.pid, p2.pid) + assert p1.is_running() + assert p2.is_running() + children = psutil.Process().children(recursive=True) + self.assertEqual(len(children), 2) + self.assertIn(p1, children) + self.assertIn(p2, children) + # make sure both or them are cleanup up + reap_children() + assert not p1.is_running() + assert not p2.is_running() + assert not psutil.tests._pids_started + assert not psutil.tests._subprocesses_started if __name__ == '__main__': |
