Skip to content

Commit

Permalink
try to adjust WindowsError.winerror
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Dec 19, 2024
1 parent 96e873d commit 6d99c46
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions psutil/tests/test_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,8 @@ def test_win_service_get(self):

# test NoSuchProcess
service = psutil.win_service_get(name)
exc = OSError(0, "msg", 0, winerror=ERROR_SERVICE_DOES_NOT_EXIST)
exc = OSError(0, "msg", 0)
exc.winerror = ERROR_SERVICE_DOES_NOT_EXIST
with mock.patch(
"psutil._psplatform.cext.winservice_query_status", side_effect=exc
):
Expand All @@ -896,7 +897,8 @@ def test_win_service_get(self):
service.username()

# test AccessDenied
exc = OSError(0, "msg", 0, winerror=ERROR_ACCESS_DENIED)
exc = OSError(0, "msg", 0)
exc.winerror = ERROR_ACCESS_DENIED
with mock.patch(
"psutil._psplatform.cext.winservice_query_status", side_effect=exc
):
Expand Down

0 comments on commit 6d99c46

Please sign in to comment.