test(core): make tests translation logic consistent with firmware
What changed, and why it matters
This commit changes only a test helper file (tests/translations.py) so that the test suite's translation lookup behaves the same way the actual device firmware does: missing or empty translated strings fall back to English. It is a test-consistency fix with no change to the firmware that runs on Trezor devices.
No security action needed. This is a test-only consistency change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies _translate_raw in tests/translations.py. Previously it returned a stored translation whenever the key existed (including empty strings). Now it uses a truthiness check (if tr:), which skips both None and empty-string values, matching the firmware’s fallback-to-English behavior. The commit title and message explicitly frame this as making tests consistent with firmware, and the [no changelog] tag indicates it is not treated as a user-visible change.
Changed components
tests/translations.pyInspect captured patch +2 / −1
diff --git a/tests/translations.py b/tests/translations.py
index 774d45cf..53bfc081 100644
--- a/tests/translations.py
+++ b/tests/translations.py
@@ -107,7 +107,8 @@ class Translation:
def _translate_raw(self, key: str, _stacklevel: int = 0) -> str:
tr = self.translations.get(key)
- if tr is not None:
+ # Emulate firmware behaviour: English strings are used instead of missing & empty strings
+ if tr:
# Handle layout-specific translations
if isinstance(tr, dict) and hasattr(_CURRENT_TRANSLATION, "LAYOUT"):
# Try to get translation for current layout
Why this scored 12/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.