Skip to content

Commit

Permalink
python 3: OSError(arg) != OSError(errno, str)
Browse files Browse the repository at this point in the history
  • Loading branch information
pajod committed Aug 17, 2024
1 parent c781bc1 commit c8a3c70
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/test_pidfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.

import os
import errno
from unittest import mock

Expand All @@ -15,7 +16,7 @@ def builtin(name):
@mock.patch(builtin('open'), new_callable=mock.mock_open)
def test_validate_no_file(_open):
pidfile = gunicorn.pidfile.Pidfile('test.pid')
_open.side_effect = IOError(errno.ENOENT)
_open.side_effect = OSError(errno.ENOENT, os.strerror(errno.ENOENT))
assert pidfile.validate() is None


Expand All @@ -37,13 +38,13 @@ def test_validate_file_pid_malformed(_open):
@mock.patch('os.kill')
def test_validate_file_pid_exists_kill_exception(kill, _open):
pidfile = gunicorn.pidfile.Pidfile('test.pid')
kill.side_effect = OSError(errno.EPERM)
kill.side_effect = OSError(errno.EPERM, os.strerror(errno.EPERM))
assert pidfile.validate() == 1


@mock.patch(builtin('open'), new_callable=mock.mock_open, read_data='1')
@mock.patch('os.kill')
def test_validate_file_pid_does_not_exist(kill, _open):
pidfile = gunicorn.pidfile.Pidfile('test.pid')
kill.side_effect = OSError(errno.ESRCH)
kill.side_effect = OSError(errno.ESRCH, os.strerror(errno.ESRCH))
assert pidfile.validate() is None

0 comments on commit c8a3c70

Please sign in to comment.