Skip to content

Commit 10f2350

Browse files
committed
Replace distutils.spawn.find_executable with shutil.which
The package distutils is deprecated and caues DeprecationWarnings. Replaced its usage with shutil.which.
1 parent 70d3751 commit 10f2350

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

pytest_services/gui.py.orig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import socket
77
import shlex
88
import subprocess32
99

10-
from distutils.spawn import find_executable
10+
from shutil import which
1111
import pytest
1212

1313
from tests.fixtures.services.util import (
@@ -70,7 +70,7 @@ def xvfb_watcher(
7070
with file_lock(
7171
os.path.join(lock_dir, 'xvfb_{0}.lock'.format(display)),
7272
operation=fcntl.LOCK_EX | fcntl.LOCK_NB):
73-
xvfb = find_executable('Xvfb')
73+
xvfb = which('Xvfb')
7474
assert xvfb, 'You have to have Xvfb installed'
7575
cmd = (
7676
'{xvfb} '

pytest_services/mysql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import shutil
44

5-
from distutils.spawn import find_executable # pylint: disable=E0611
5+
from shutil import which
66
import pytest
77

88
from .process import (
@@ -31,7 +31,7 @@ def mysql_defaults_file(
3131

3232
@pytest.fixture(scope='session')
3333
def mysql_base_dir():
34-
my_print_defaults = find_executable('my_print_defaults')
34+
my_print_defaults = which('my_print_defaults')
3535
assert my_print_defaults, 'You have to install my_print_defaults script.'
3636

3737
return os.path.dirname(os.path.dirname(os.path.realpath(my_print_defaults)))
@@ -49,7 +49,7 @@ def mysql_system_database(
4949
):
5050
"""Install database to given path."""
5151
if run_services:
52-
mysqld = find_executable('mysqld')
52+
mysqld = which('mysqld')
5353
assert mysqld, 'You have to install mysqld script.'
5454

5555
try:

pytest_services/service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import subprocess
99
import uuid # pylint: disable=C0411
1010

11-
from distutils.spawn import find_executable # pylint: disable=E0611
11+
from shutil import which
1212
import pytest
1313

1414
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
7070
if request is None:
7171
warnings.warn('Omitting the `request` parameter will result in an unstable order of finalizers.')
7272
request = orig_request
73-
executable = find_executable(name)
73+
executable = which(name)
7474
assert executable, 'You have to install {0} executable.'.format(name)
7575

7676
cmd = [name] + (arguments or [])

0 commit comments

Comments
 (0)