Skip to content

test(core): fix broken log suppression in unit tests#6558

Merged
M1nd3r merged 1 commit into
mainfrom
m1nd3r/unittest-log-suppression
Mar 5, 2026
Merged

test(core): fix broken log suppression in unit tests#6558
M1nd3r merged 1 commit into
mainfrom
m1nd3r/unittest-log-suppression

Conversation

@M1nd3r
Copy link
Copy Markdown
Contributor

@M1nd3r M1nd3r commented Mar 5, 2026

This PR:

  • Fixes broken suppression of logging in core python unit tests

@M1nd3r M1nd3r self-assigned this Mar 5, 2026
@M1nd3r M1nd3r requested a review from obrusvit as a code owner March 5, 2026 13:48
@M1nd3r M1nd3r requested a review from romanz March 5, 2026 13:48
@trezor-bot trezor-bot Bot added this to Firmware Mar 5, 2026
@github-project-automation github-project-automation Bot moved this to 🔎 Needs review in Firmware Mar 5, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6dcf9fdf-9f0b-47aa-a3dd-c7bb8d0bdad0

📥 Commits

Reviewing files that changed from the base of the PR and between d8c872b and 0acf712.

📒 Files selected for processing (11)
  • core/tests/README.md
  • core/tests/test_apps.bitcoin.approver.py
  • core/tests/test_apps.bitcoin.authorization.py
  • core/tests/test_apps.bitcoin.keychain.py
  • core/tests/test_apps.common.keychain.py
  • core/tests/test_apps.ethereum.keychain.py
  • core/tests/test_storage.cache.py
  • core/tests/test_trezor.wire.thp.crypto.py
  • core/tests/test_trezor.wire.thp.writer.py
  • core/tests/thp_common.py
  • core/tests/unittest.py
💤 Files with no reviewable changes (9)
  • core/tests/test_apps.bitcoin.authorization.py
  • core/tests/test_trezor.wire.thp.crypto.py
  • core/tests/test_apps.bitcoin.keychain.py
  • core/tests/test_apps.ethereum.keychain.py
  • core/tests/test_storage.cache.py
  • core/tests/test_apps.common.keychain.py
  • core/tests/test_apps.bitcoin.approver.py
  • core/tests/test_trezor.wire.thp.writer.py
  • core/tests/thp_common.py
✅ Files skipped from review due to trivial changes (1)
  • core/tests/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/tests/unittest.py

Walkthrough

The 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
Loading
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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The pull request description is minimal and lacks required sections from the template such as PR setup details, development status tracking, and QA instructions for core developers. Expand the description to include relevant template sections: assign yourself, add to Firmware project, set priority/team/sprint, and indicate development status (Draft/Needs Review).
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing broken log suppression in core Python unit tests, which aligns with the actual changes across multiple test files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch m1nd3r/unittest-log-suppression

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@M1nd3r M1nd3r mentioned this pull request Mar 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 5, 2026

en main(all)

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 95dc302 and d8c872b.

📒 Files selected for processing (11)
  • core/tests/README.md
  • core/tests/test_apps.bitcoin.approver.py
  • core/tests/test_apps.bitcoin.authorization.py
  • core/tests/test_apps.bitcoin.keychain.py
  • core/tests/test_apps.common.keychain.py
  • core/tests/test_apps.ethereum.keychain.py
  • core/tests/test_storage.cache.py
  • core/tests/test_trezor.wire.thp.crypto.py
  • core/tests/test_trezor.wire.thp.writer.py
  • core/tests/thp_common.py
  • core/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

Comment thread core/tests/unittest.py Outdated
Copy link
Copy Markdown
Contributor

@romanz romanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@M1nd3r M1nd3r force-pushed the m1nd3r/unittest-log-suppression branch from d8c872b to 0acf712 Compare March 5, 2026 13:57
@M1nd3r M1nd3r merged commit 0da61de into main Mar 5, 2026
100 checks passed
@M1nd3r M1nd3r deleted the m1nd3r/unittest-log-suppression branch March 5, 2026 14:15
@github-project-automation github-project-automation Bot moved this from 🔎 Needs review to 🤝 Needs QA in Firmware Mar 5, 2026
@M1nd3r M1nd3r moved this from 🤝 Needs QA to ✅ Done (no QA) in Firmware Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants