From c8a3c70328bab458cc7a343a20ce075fc29d526d Mon Sep 17 00:00:00 2001 From: "Paul J. Dorn" Date: Sat, 17 Aug 2024 02:23:26 +0200 Subject: [PATCH] python 3: OSError(arg) != OSError(errno, str) --- tests/test_pidfile.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_pidfile.py b/tests/test_pidfile.py index 81bb9d206..576f76c24 100644 --- a/tests/test_pidfile.py +++ b/tests/test_pidfile.py @@ -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 @@ -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 @@ -37,7 +38,7 @@ 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 @@ -45,5 +46,5 @@ def test_validate_file_pid_exists_kill_exception(kill, _open): @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