summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-04-21 17:25:23 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-04-21 17:25:23 +0200
commita115de4a07627cd7676a4c2da141a1c856d7af96 (patch)
tree63b06861c5520df98fae730717e54306c3c1da32
parent22651a6ca3142aeb405b0c23b4f668ed6d3f1de3 (diff)
downloadpsutil-a115de4a07627cd7676a4c2da141a1c856d7af96.tar.gz
test case for #1014
-rwxr-xr-xpsutil/tests/test_linux.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index 2d37b464..eec33546 100755
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -1397,6 +1397,24 @@ class TestProcess(unittest.TestCase):
return_value=False):
self.assertRaises(psutil.ZombieProcess, psutil.Process().exe)
+ def test_issue_1014(self):
+ # Emulates a case where smaps file does not exist. In this case
+ # wrap_exception decorator should not raise NoSuchProcess.
+ def open_mock(name, *args, **kwargs):
+ if name.startswith('/proc/%s/smaps' % os.getpid()):
+ raise IOError(errno.ENOENT, "")
+ else:
+ return orig_open(name, *args, **kwargs)
+
+ orig_open = open
+ patch_point = 'builtins.open' if PY3 else '__builtin__.open'
+ with mock.patch(patch_point, side_effect=open_mock) as m:
+ p = psutil.Process()
+ with self.assertRaises(IOError) as err:
+ p.memory_maps()
+ self.assertEqual(err.exception.errno, errno.ENOENT)
+ assert m.called
+
@unittest.skipUnless(LINUX, "LINUX only")
class TestProcessAgainstStatus(unittest.TestCase):