Skip to content

Commit d38ade7

Browse files
committed
qa: Use sys.executable when invoking other Python scripts
This change fixes tests on systems where `python3` is not available in the `PATH`, causing the shebang `#!/usr/bin/env python3` to fail.
1 parent c1252b1 commit d38ade7

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

test/functional/rpc_signer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010
import os
1111
import platform
12+
import sys
1213

1314
from test_framework.test_framework import BitcoinTestFramework
1415
from test_framework.util import (
@@ -20,10 +21,7 @@
2021
class RPCSignerTest(BitcoinTestFramework):
2122
def mock_signer_path(self):
2223
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'signer.py')
23-
if platform.system() == "Windows":
24-
return "py -3 " + path
25-
else:
26-
return path
24+
return sys.executable + " " + path
2725

2826
def set_test_params(self):
2927
self.num_nodes = 4

test/functional/wallet_signer.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
See also rpc_signer.py for tests without wallet context.
99
"""
1010
import os
11-
import platform
11+
import sys
1212

1313
from test_framework.test_framework import BitcoinTestFramework
1414
from test_framework.util import (
@@ -24,24 +24,15 @@ def add_options(self, parser):
2424

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

3229
def mock_invalid_signer_path(self):
3330
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'invalid_signer.py')
34-
if platform.system() == "Windows":
35-
return "py -3 " + path
36-
else:
37-
return path
31+
return sys.executable + " " + path
3832

3933
def mock_multi_signers_path(self):
4034
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'multi_signers.py')
41-
if platform.system() == "Windows":
42-
return "py -3 " + path
43-
else:
44-
return path
35+
return sys.executable + " " + path
4536

4637
def set_test_params(self):
4738
self.num_nodes = 2

0 commit comments

Comments
 (0)