test: Move export_env_build_path to util.py
What changed, and why it matters
This commit simply moves a small helper function from one test file to another. It does not change what the code does, only where the code lives. There is no security issue here.
No action needed. This is a benign test-only refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors the test framework by extracting the PATH export logic into a new export_env_build_path() function in util.py and calling it from test_framework.py. The behavior is identical: it prepends the build directory’s bin path to os.environ['PATH']. No functional or security-relevant change is introduced.
Changed components
test/functional/test_framework/test_framework.pytest/functional/test_framework/util.pyInspect captured patch +9 / −5
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 58933c9d..50312021 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -31,6 +31,7 @@ from .util import (
PortSeed,
assert_equal,
check_json_precision,
+ export_env_build_path,
find_vout_for_address,
get_binary_paths,
get_datadir_path,
@@ -226,14 +227,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
"""Call this method to start up the test framework object with options set."""
check_json_precision()
+ export_env_build_path(self.config)
self.options.cachedir = os.path.abspath(self.options.cachedir)
- os.environ['PATH'] = os.pathsep.join([
- os.path.join(self.config["environment"]["BUILDDIR"], "bin"),
- os.environ['PATH']
- ])
-
# Set up temp directory and start logging
if self.options.tmpdir:
self.options.tmpdir = os.path.abspath(self.options.tmpdir)
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index 4ee65494..b9f1b488 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -322,6 +322,13 @@ def get_binary_paths(config):
return paths
+def export_env_build_path(config):
+ os.environ["PATH"] = os.pathsep.join([
+ os.path.join(config["environment"]["BUILDDIR"], "bin"),
+ os.environ["PATH"],
+ ])
+
+
def count_bytes(hex_string):
return len(bytearray.fromhex(hex_string))
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.