summaryrefslogtreecommitdiff
path: root/psutil/tests
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2019-04-04 09:55:03 -0700
committerGiampaolo Rodola <g.rodola@gmail.com>2019-04-04 09:55:03 -0700
commitc9162ae0f76fd4ba8d0e8c80808df23a2b9c23c4 (patch)
tree2aec80c9dd39009c4f9b664dd706be6b86d071a8 /psutil/tests
parent7b8c8f522ca8db3d8bf6fb7a8d627f904ab4dbba (diff)
downloadpsutil-winerr-handling.tar.gz
properly check OSError.winerrorwinerr-handling
Diffstat (limited to 'psutil/tests')
-rwxr-xr-xpsutil/tests/test_windows.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py
index a3a6b61d..70c99b4b 100755
--- a/psutil/tests/test_windows.py
+++ b/psutil/tests/test_windows.py
@@ -664,17 +664,15 @@ class TestDualProcessImplementation(unittest.TestCase):
assert fun.called
def test_cmdline(self):
- from psutil._pswindows import ACCESS_DENIED_ERRSET
+ from psutil._pswindows import convert_oserror
for pid in psutil.pids():
try:
a = cext.proc_cmdline(pid, use_peb=True)
b = cext.proc_cmdline(pid, use_peb=False)
except OSError as err:
- if err.errno in ACCESS_DENIED_ERRSET:
- pass
- elif err.errno == errno.ESRCH:
- pass # NSP
- else:
+ err = convert_oserror(err)
+ if not isinstance(err, (psutil.AccessDenied,
+ psutil.NoSuchProcess)):
raise
else:
self.assertEqual(a, b)
@@ -837,7 +835,8 @@ class TestServices(unittest.TestCase):
# test NoSuchProcess
service = psutil.win_service_get(name)
exc = WindowsError(
- psutil._psplatform.cext.ERROR_SERVICE_DOES_NOT_EXIST, "")
+ 0, "", 0,
+ psutil._psplatform.cext.ERROR_SERVICE_DOES_NOT_EXIST)
with mock.patch("psutil._psplatform.cext.winservice_query_status",
side_effect=exc):
self.assertRaises(psutil.NoSuchProcess, service.status)
@@ -847,7 +846,8 @@ class TestServices(unittest.TestCase):
# test AccessDenied
exc = WindowsError(
- psutil._psplatform.cext.ERROR_ACCESS_DENIED, "")
+ 0, "", 0,
+ psutil._psplatform.cext.ERROR_ACCESS_DENIED)
with mock.patch("psutil._psplatform.cext.winservice_query_status",
side_effect=exc):
self.assertRaises(psutil.AccessDenied, service.status)