Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Aug 1, 2023
1 parent 7dd69dd commit 0c4a569
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions psutil/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,26 +959,36 @@ def assertProcessGone(self, proc):

def assertProcessZombie(self, proc):
# A zombie process should always be instantiable.
clone = psutil.Process(proc.pid)
self.assertEqual(proc, clone)
psutil.Process(proc.pid)
# Its status always be querable.
self.assertEqual(proc.status(), psutil.STATUS_ZOMBIE)
# It should be considered 'running'.
assert proc.is_running()
# as_dict() shouldn't crash.
proc.as_dict()
# Terminate and kill should not be possible.
# It should show up in pids() and process_iter().
self.assertIn(proc.pid, psutil.pids())
self.assertIn(proc.pid, [x.pid for x in psutil.process_iter()])
# It cannot be signaled or terminated.
proc.suspend()
proc.resume()
proc.terminate()
proc.kill()
assert proc.is_running()
# Its parent should 'see' it (edit: not true on BSD and MACOS

# Its parent should 'see' it (edit: not true on BSD and MACOS).
# descendants = [x.pid for x in psutil.Process().children(
# recursive=True)]
# self.assertIn(zpid, descendants)
# XXX should we also assume ppid be usable? Note: this
# self.assertIn(proc.pid, descendants)

# __eq__ can't be relied upon because creation time may not be
# querable.
# self.assertEqual(proc, psutil.Process(proc.pid))

# XXX should we also assume ppid() to be usable? Note: this
# would be an important use case as the only way to get
# rid of a zombie is to kill its parent.
# self.assertEqual(zpid.ppid(), os.getpid())
# self.assertEqual(proc.ppid(), os.getpid())


@unittest.skipIf(PYPY, "unreliable on PYPY")
Expand Down

0 comments on commit 0c4a569

Please sign in to comment.