Skip to content

Commit

Permalink
qa: Use sys.executable when invoking other Python scripts
Browse files Browse the repository at this point in the history
This change fixes tests on systems where `python3` is not available
in the `PATH`, causing the shebang `#!/usr/bin/env python3` to fail.
  • Loading branch information
hebasto committed Dec 19, 2024
1 parent c1252b1 commit d38ade7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
6 changes: 2 additions & 4 deletions test/functional/rpc_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""
import os
import platform
import sys

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
Expand All @@ -20,10 +21,7 @@
class RPCSignerTest(BitcoinTestFramework):
def mock_signer_path(self):
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'signer.py')
if platform.system() == "Windows":
return "py -3 " + path
else:
return path
return sys.executable + " " + path

def set_test_params(self):
self.num_nodes = 4
Expand Down
17 changes: 4 additions & 13 deletions test/functional/wallet_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
See also rpc_signer.py for tests without wallet context.
"""
import os
import platform
import sys

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
Expand All @@ -24,24 +24,15 @@ def add_options(self, parser):

def mock_signer_path(self):
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'signer.py')
if platform.system() == "Windows":
return "py -3 " + path
else:
return path
return sys.executable + " " + path

def mock_invalid_signer_path(self):
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'invalid_signer.py')
if platform.system() == "Windows":
return "py -3 " + path
else:
return path
return sys.executable + " " + path

def mock_multi_signers_path(self):
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'multi_signers.py')
if platform.system() == "Windows":
return "py -3 " + path
else:
return path
return sys.executable + " " + path

def set_test_params(self):
self.num_nodes = 2
Expand Down

0 comments on commit d38ade7

Please sign in to comment.