diff --git a/tests/nodeenv_test.py b/tests/nodeenv_test.py index ecf182c..9526575 100644 --- a/tests/nodeenv_test.py +++ b/tests/nodeenv_test.py @@ -3,6 +3,7 @@ import os.path import pipes +import shutil import subprocess import sys import sysconfig @@ -15,12 +16,15 @@ HERE = os.path.abspath(os.path.dirname(__file__)) - -if subprocess.run(["which", "nodejs"],capture_output=True).returncode == 0: - is_nodejs = True -else: - is_nodejs = False - +try: + is_nodejs = shutil.which("nodejs") is not None +except AttributeError: + try: + subprocess.check_call(["which", "nodejs"], stdout=subprocess.PIPE) + except subprocess.CalledProcessError: + is_nodejs = False + else: + is_nodejs = True def call_nodejs(ev_path): assert os.path.exists(ev_path)