Skip to content

Commit

Permalink
Fix test asserts due to leftover test subprocesses (#1161)
Browse files Browse the repository at this point in the history
* Reap test subprocess.

The leftover child process was triggering an assert in a later test:

======================================================================
FAIL: psutil.tests.test_connections.TestConnectedSocketPairs.test_combos
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ade/projects/psutil/psutil/tests/__init__.py", line 792, in wrapper
    return fun(*args, **kwargs)
  File "/home/ade/projects/psutil/psutil/tests/test_connections.py", line 330, in test_combos
    self.assertEqual(len(cons), 1)
AssertionError: 0 != 1

* Inherit from Base so that reap_children() cleans up the test processes.

Fixes memory leak test asserts.

psutil/tests/test_memory_leaks.py:334:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
psutil/tests/test_memory_leaks.py:125: in execute
    self.assertEqual(thisproc.children(), [])
E   AssertionError: Lists differ: [<psutil.Process(pid=908, name... != []
E
E   First list contains 10 additional elements.
E   First extra element 0:
E   <psutil.Process(pid=908, name='python2.7') at 34513317008>
E
E   + []
E   - [<psutil.Process(pid=908, name='python2.7') at 34513317008>,
E   -  <psutil.Process(pid=909, name='python2.7') at 34459063760>,
E   -  <psutil.Process(pid=910, name='python2.7') at 34459064464>,
E   -  <psutil.Process(pid=911, name='python2.7') at 34513749456>,
E   -  <psutil.Process(pid=912, name='python2.7') at 34513749520>,
E   -  <psutil.Process(pid=913, name='python2.7') at 34513751184>,
E   -  <psutil.Process(pid=914, name='python2.7') at 34513751120>,
E   -  <psutil.Process(pid=915, name='python2.7') at 34513751312>,
E   -  <psutil.Process(pid=916, name='python2.7') at 34513751376>,
E   -  <psutil.Process(pid=917, name='python2.7') at 34513748176>]
  • Loading branch information
Adrian Page authored and giampaolo committed Oct 28, 2017
1 parent 3cec630 commit 5c51581
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion psutil/tests/test_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def test_multi_sockets_filtering(self):
# =====================================================================


class TestSystemWideConnections(unittest.TestCase):
class TestSystemWideConnections(Base, unittest.TestCase):
"""Tests for net_connections()."""

@skip_on_access_denied()
Expand Down
1 change: 1 addition & 0 deletions psutil/tests/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ def test_proc_environ(self):
self.assertIsInstance(k, str)
self.assertIsInstance(v, str)
self.assertEqual(env['FUNNY_ARG'], funky_str)
reap_children()


if __name__ == '__main__':
Expand Down

0 comments on commit 5c51581

Please sign in to comment.