diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2019-04-05 16:54:48 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2019-04-05 16:54:48 +0200 |
commit | b24c552bc0a18ba894ae39907167e903dcafa924 (patch) | |
tree | bc17e8b2bcc7b81fe7c4a1a2b3413d4fffbe36df | |
parent | 3f67688df6c47eec3427c001ef1f11b14e6fcaf2 (diff) | |
parent | 2eb7b3bc2982f94afee4f4cbd93764d9708e206d (diff) | |
download | psutil-b24c552bc0a18ba894ae39907167e903dcafa924.tar.gz |
Merge branch 'master' of github.com:giampaolo/psutil
-rwxr-xr-x | psutil/tests/test_windows.py | 22 | ||||
-rwxr-xr-x | scripts/internal/.git-pre-commit | 3 |
2 files changed, 17 insertions, 8 deletions
diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py index 70c99b4b..5a998dd4 100755 --- a/psutil/tests/test_windows.py +++ b/psutil/tests/test_windows.py @@ -25,6 +25,7 @@ from psutil.tests import APPVEYOR from psutil.tests import get_test_subprocess from psutil.tests import HAS_BATTERY from psutil.tests import mock +from psutil.tests import PY3 from psutil.tests import reap_children from psutil.tests import retry_on_failure from psutil.tests import sh @@ -826,17 +827,22 @@ class TestServices(unittest.TestCase): self.assertEqual(serv, s) def test_win_service_get(self): - name = next(psutil.win_service_iter()).name() + ERROR_SERVICE_DOES_NOT_EXIST = \ + psutil._psplatform.cext.ERROR_SERVICE_DOES_NOT_EXIST + ERROR_ACCESS_DENIED = psutil._psplatform.cext.ERROR_ACCESS_DENIED + name = next(psutil.win_service_iter()).name() with self.assertRaises(psutil.NoSuchProcess) as cm: psutil.win_service_get(name + '???') self.assertEqual(cm.exception.name, name + '???') # test NoSuchProcess service = psutil.win_service_get(name) - exc = WindowsError( - 0, "", 0, - psutil._psplatform.cext.ERROR_SERVICE_DOES_NOT_EXIST) + if PY3: + args = (0, "msg", 0, ERROR_SERVICE_DOES_NOT_EXIST) + else: + args = (ERROR_SERVICE_DOES_NOT_EXIST, "msg") + exc = WindowsError(*args) with mock.patch("psutil._psplatform.cext.winservice_query_status", side_effect=exc): self.assertRaises(psutil.NoSuchProcess, service.status) @@ -845,9 +851,11 @@ class TestServices(unittest.TestCase): self.assertRaises(psutil.NoSuchProcess, service.username) # test AccessDenied - exc = WindowsError( - 0, "", 0, - psutil._psplatform.cext.ERROR_ACCESS_DENIED) + if PY3: + args = (0, "msg", 0, ERROR_ACCESS_DENIED) + else: + args = (ERROR_ACCESS_DENIED, "msg") + exc = WindowsError(*args) with mock.patch("psutil._psplatform.cext.winservice_query_status", side_effect=exc): self.assertRaises(psutil.AccessDenied, service.status) diff --git a/scripts/internal/.git-pre-commit b/scripts/internal/.git-pre-commit index c3c605e0..c7d7d1ff 100755 --- a/scripts/internal/.git-pre-commit +++ b/scripts/internal/.git-pre-commit @@ -79,8 +79,9 @@ def main(): os.path.exists(x)] lineno = 0 + kw = {'encoding': 'utf8'} if sys.version_info[0] == 3 else {} for path in py_files: - with open(path) as f: + with open(path, 'rt', **kw) as f: for line in f: lineno += 1 # space at end of line |