test(core): avoid manipulating `sys.path`
What changed, and why it matters
This is a minor test-only cleanup. It removes a hardcoded path tweak inside the test helper file and sets the same search path through an environment variable in the test runner script instead. There is no change to the actual Trezor firmware or wallet security.
No security action needed; this is a routine test infrastructure refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors how MicroPython finds the ../src directory during test execution. Previously core/tests/common.py appended ../src to sys.path at import time; now core/tests/run_tests.sh exports MICROPYPATH=.:../src before invoking the tests. Functionally equivalent for tests, no runtime firmware code is touched.
Changed components
core/tests/common.pycore/tests/run_tests.shInspect captured patch +2 / −4
diff --git a/core/tests/common.py b/core/tests/common.py
index 03e69bc00..8b0494e30 100644
--- a/core/tests/common.py
+++ b/core/tests/common.py
@@ -1,7 +1,3 @@
-import sys
-
-sys.path.append("../src")
-
import unittest # noqa: F401
from typing import Any, Awaitable
from ubinascii import hexlify, unhexlify # noqa: F401
diff --git a/core/tests/run_tests.sh b/core/tests/run_tests.sh
index aefa998d2..de858fce2 100755
--- a/core/tests/run_tests.sh
+++ b/core/tests/run_tests.sh
@@ -26,6 +26,8 @@ cd $(dirname $0)
declare -i num_of_tests=${#tests[@]}
+export MICROPYPATH=.:../src # for tests' imports to work as expected
+
for test_case in ${tests[@]}; do
echo
if $MICROPYTHON $test_case; then
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.