From e52127d88725aa9f7d8fec188d74e9edbe38a957 Mon Sep 17 00:00:00 2001 From: Ayman Zaher <11262003a@gmail.com> Date: Thu, 19 Jun 2025 01:04:59 -0400 Subject: [PATCH] Replace distutils.spawn.find_executable with shutil.which The package distutils is deprecated and caues DeprecationWarnings. Replaced its usage with shutil.which. --- pytest_services/gui.py.orig | 4 ++-- pytest_services/service.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pytest_services/gui.py.orig b/pytest_services/gui.py.orig index 9fd2fb1..911b442 100644 --- a/pytest_services/gui.py.orig +++ b/pytest_services/gui.py.orig @@ -7,7 +7,7 @@ import socket import shlex import subprocess32 -from distutils.spawn import find_executable +from shutil import which import pytest from tests.fixtures.services.util import ( @@ -70,7 +70,7 @@ def xvfb_watcher( with file_lock( os.path.join(lock_dir, 'xvfb_{0}.lock'.format(display)), operation=fcntl.LOCK_EX | fcntl.LOCK_NB): - xvfb = find_executable('Xvfb') + xvfb = which('Xvfb') assert xvfb, 'You have to have Xvfb installed' cmd = ( '{xvfb} ' diff --git a/pytest_services/service.py b/pytest_services/service.py index 2f57302..1c9407e 100644 --- a/pytest_services/service.py +++ b/pytest_services/service.py @@ -8,7 +8,7 @@ import subprocess import uuid # pylint: disable=C0411 -from distutils.spawn import find_executable # pylint: disable=E0611 +from shutil import which import pytest WRONG_FILE_NAME_CHARS_RE = re.compile(r'[^\w_-]') @@ -70,7 +70,7 @@ def watcher_getter_function(name, arguments=None, kwargs=None, timeout=20, check if request is None: warnings.warn('Omitting the `request` parameter will result in an unstable order of finalizers.') request = orig_request - executable = find_executable(name) + executable = which(name) assert executable, 'You have to install {0} executable.'.format(name) cmd = [name] + (arguments or [])