diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-17 13:59:59 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-17 13:59:59 +0200 |
commit | b4b3e59f0f95ebf7f138763ce259c1d7ea9ffb5f (patch) | |
tree | ffda9e396d0e2dcedb430553757c7708692a4381 | |
parent | 91041c4e1f20b48d5841a2aaacc90a106c4b4f6c (diff) | |
download | psutil-b4b3e59f0f95ebf7f138763ce259c1d7ea9ffb5f.tar.gz |
test utils refactoring
-rw-r--r-- | psutil/tests/__init__.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 2f852ef3..1206abff 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -378,6 +378,20 @@ def reap_children(recursive=False): If resursive is True it also tries to terminate and wait() all grandchildren started by this process. """ + # This is here to make sure wait_procs() behaves properly and + # investigate: + # https://ci.appveyor.com/project/giampaolo/psutil/build/job/ + # jiq2cgd6stsbtn60 + def assert_gone(pid): + assert not psutil.pid_exists(pid), pid + assert pid not in psutil.pids(), pid + try: + psutil.Process(pid) + except psutil.NoSuchProcess: + pass + else: + assert 0, "pid %s is not gone" % pid + # Get the children here, before terminating the children sub # processes as we don't want to lose the intermediate reference # in case of grandchildren. @@ -410,6 +424,7 @@ def reap_children(recursive=False): except OSError as err: if err.errno != errno.ECHILD: raise + assert_gone(subp.pid) # Terminate started pids. while _pids_started: @@ -440,12 +455,8 @@ def reap_children(recursive=False): for p in alive: warn("process %r survived kill()" % p) - # TODO: this is temporary and here only to investigate: - # https://ci.appveyor.com/project/giampaolo/psutil/build/job/ - # jiq2cgd6stsbtn60 for p in children: - assert not psutil.pid_exists(p.pid), p - assert p.pid not in psutil.pids() + assert_gone(p.pid) # =================================================================== |