Skip to content

Commit

Permalink
tests: support python releases before 3.7
Browse files Browse the repository at this point in the history
the "capture_output" parameter of subprocess.run() was introduced in
python3.7.
and subprocess.run() does not exist in python2. so should not rely on
them unless we drop the support of python2 and python3.6

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
  • Loading branch information
tchaikov committed Oct 6, 2020
1 parent c9ee277 commit f519a62
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/nodeenv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import os.path
import pipes
import shutil
import subprocess
import sys
import sysconfig
Expand All @@ -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)
Expand Down

0 comments on commit f519a62

Please sign in to comment.