Use shutil.which to avoid distutils+imp warning

This commit is contained in:
Anthony Sottile 2019-06-27 11:08:31 -07:00
parent 97f0a20ca9
commit 58bfc7736f
2 changed files with 3 additions and 9 deletions

View File

@ -2,7 +2,7 @@
module containing a parametrized tests testing cross-python module containing a parametrized tests testing cross-python
serialization via the pickle module. serialization via the pickle module.
""" """
import distutils.spawn import shutil
import subprocess import subprocess
import textwrap import textwrap
@ -24,7 +24,7 @@ def python2(request, python1):
class Python: class Python:
def __init__(self, version, picklefile): def __init__(self, version, picklefile):
self.pythonpath = distutils.spawn.find_executable(version) self.pythonpath = shutil.which(version)
if not self.pythonpath: if not self.pythonpath:
pytest.skip("{!r} not found".format(version)) pytest.skip("{!r} not found".format(version))
self.picklefile = picklefile self.picklefile = picklefile

View File

@ -435,15 +435,9 @@ Running it results in some skips if we don't have all the python interpreters in
. $ pytest -rs -q multipython.py . $ pytest -rs -q multipython.py
ssssssssssss......sss...... [100%] ssssssssssss......sss...... [100%]
============================= warnings summary =============================
$PYTHON_PREFIX/lib/python3.6/distutils/__init__.py:1
$PYTHON_PREFIX/lib/python3.6/distutils/__init__.py:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/latest/warnings.html
========================= short test summary info ========================== ========================= short test summary info ==========================
SKIPPED [15] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found SKIPPED [15] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found
12 passed, 15 skipped, 1 warnings in 0.12 seconds 12 passed, 15 skipped in 0.12 seconds
Indirect parametrization of optional implementations/imports Indirect parametrization of optional implementations/imports
-------------------------------------------------------------------- --------------------------------------------------------------------