What changed, and why it matters
This commit fixes how the project's test scripts set up Python's module search path and how they detect a missing optional dependency. It only changes files inside the 'test/' directory, which are used for running automated tests on a regular computer, not the actual hardware wallet firmware. There is no indication this fixes a security vulnerability.
No security action required. Treat as a normal test-infrastructure fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies two test helper scripts. In run_native_tests.py, it changes sys.path manipulation so the local ‘src’ directory is inserted at position 1 (after the current directory) rather than position 0, and other library paths are appended at the end instead of prepended. In native_support.py, it adds ‘import embit.util’ before importing Wallet and changes the missing-dependency check from ‘exc.name == “embit”’ to ‘exc.name.startswith(“embit”)’. These are test-environment import-order and error-message fixes.
Changed components
test/native_support.pytest/run_native_tests.pyInspect captured patch +16 / −7
diff --git a/test/native_support.py b/test/native_support.py
index 8535506..4ebb626 100644
--- a/test/native_support.py
+++ b/test/native_support.py
@@ -23,7 +23,8 @@ def _ensure_submodule(package, name, attrs):
setattr(parent, name, module)
return module
-
+# The setup_native_stubs() function creates mock/stub implementations of
+# MicroPython-specific modules that don't exist in regular Python
def setup_native_stubs():
if sys.implementation.name == 'micropython':
return
@@ -188,9 +189,10 @@ def setup_native_stubs():
BaseApp.get_prefix = _native_get_prefix
try:
+ import embit.util
from apps.wallets.wallet import Wallet as _Wallet
except ModuleNotFoundError as exc:
- if exc.name == "embit":
+ if exc.name.startswith("embit"):
raise ModuleNotFoundError(
"Native test suite requires the 'embit' package. "
"Install it with 'pip install -r test/integration/requirements.txt'."
diff --git a/test/run_native_tests.py b/test/run_native_tests.py
index 3708cd3..1dd957f 100644
--- a/test/run_native_tests.py
+++ b/test/run_native_tests.py
@@ -2,11 +2,18 @@ import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
-sys.path.insert(0, str((ROOT / "../src").resolve()))
-sys.path.insert(0, str((ROOT / "../f469-disco/libs/common").resolve()))
-sys.path.insert(0, str((ROOT / "../f469-disco/libs/unix").resolve()))
-sys.path.insert(0, str((ROOT / "../f469-disco/usermods/udisplay_f469/display_unixport").resolve()))
-sys.path.insert(0, str((ROOT / "../f469-disco/tests").resolve()))
+# Insert src directly after the local dir (highest prio)
+sys.path.insert(1, str((ROOT / "../src").resolve()))
+
+# make the other stuff available with lowest prio
+sys.path.append(str((ROOT / "../f469-disco/libs/common").resolve()))
+sys.path.append(str((ROOT / "../f469-disco/libs/unix").resolve()))
+sys.path.append(str((ROOT / "../f469-disco/usermods/udisplay_f469/display_unixport").resolve()))
+sys.path.append(str((ROOT / "../f469-disco/tests").resolve()))
+
+# uncomment if import issues
+#print("Import priotisation:")
+#print('\n'.join(f'{i}: {p}' for i, p in enumerate(sys.path[:10])))
from native_support import setup_native_stubs
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.