test(core): fix broken log suppression in unit tests#6558
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
💤 Files with no reviewable changes (9)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe diff centralizes test log suppression. Per-test conditional suppression blocks and some test-level constructors were removed from multiple test files and thp_common.py. A new global flag DISABLE_LOG and a TestRunner.init were added to core/tests/unittest.py; TestRunner now conditionally calls set_log_filter("-*") based on DISABLE_LOG and trezor.utils.USE_DBG_CONSOLE. A brief Logging section was added to core/tests/README.md documenting how to enable logging in unittests. Sequence Diagram(s)sequenceDiagram
participant TestRunner as TestRunner (core/tests/unittest.py)
participant Utils as trezor.utils
participant Logger as log module
Note over TestRunner,Logger: New centralized flow during test startup
TestRunner->>Utils: check USE_DBG_CONSOLE
TestRunner->>TestRunner: check DISABLE_LOG
alt DISABLE_LOG and USE_DBG_CONSOLE true
TestRunner->>Logger: set_log_filter("-*")
end
TestRunner->>Tests: start test run
sequenceDiagram
participant TestCase as Individual Test Classes
participant THP as thp_common
participant Logger as log module
Note over TestCase,Logger: Previous per-test suppression (removed)
TestCase->>THP: thp_common.suppress_debug_log() (guarded by __debug__)
THP->>Logger: lower verbosity / suppress debug
TestCase->>TestCase: proceed with setUp / tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| model | device_test | click_test | persistence_test |
|---|---|---|---|
| T2T1 | test(all) main(all) ![]() |
test(all) main(all) ![]() |
test(all) main(all) ![]() |
| T3B1 | test(all) main(all) ![]() |
test(all) main(all) ![]() |
test(all) main(all) ![]() |
| T3T1 | test(all) main(all) ![]() |
test(all) main(all) ![]() |
test(all) main(all) ![]() |
| T3W1 | test(all) main(all) ![]() |
test(all) main(all) ![]() |
test(all) main(all) ![]() |
Latest CI run: 22721261928
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@core/tests/unittest.py`:
- Around line 232-237: In __init__ where you currently do "if __debug__ and
DISABLE_LOG: from trezor.utils import set_log_filter; set_log_filter('-*')", add
a guard to check USE_DBG_CONSOLE first (e.g., only import and call
set_log_filter if USE_DBG_CONSOLE is true) so the import from trezor.utils is
only attempted when set_log_filter is available; alternatively wrap the
import/call in a try/except ImportError and skip gracefully—refer to the
existing pattern in core/src/apps/debug/__init__.py for how USE_DBG_CONSOLE is
checked before importing set_log_filter.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 11eb696a-cbd8-4658-8f91-7c819336ff55
📒 Files selected for processing (11)
core/tests/README.mdcore/tests/test_apps.bitcoin.approver.pycore/tests/test_apps.bitcoin.authorization.pycore/tests/test_apps.bitcoin.keychain.pycore/tests/test_apps.common.keychain.pycore/tests/test_apps.ethereum.keychain.pycore/tests/test_storage.cache.pycore/tests/test_trezor.wire.thp.crypto.pycore/tests/test_trezor.wire.thp.writer.pycore/tests/thp_common.pycore/tests/unittest.py
💤 Files with no reviewable changes (9)
- core/tests/test_apps.bitcoin.keychain.py
- core/tests/thp_common.py
- core/tests/test_apps.common.keychain.py
- core/tests/test_trezor.wire.thp.crypto.py
- core/tests/test_trezor.wire.thp.writer.py
- core/tests/test_apps.bitcoin.approver.py
- core/tests/test_apps.ethereum.keychain.py
- core/tests/test_storage.cache.py
- core/tests/test_apps.bitcoin.authorization.py
[no changelog]
d8c872b to
0acf712
Compare




































This PR: