Skip to content

Commit 0da61de

Browse files
committed
test(core): fix broken log suppression in unit tests
[no changelog]
1 parent 95dc302 commit 0da61de

11 files changed

Lines changed: 15 additions & 35 deletions

core/tests/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ class TestSomething(unittest.TestCase):
3030
```
3131

3232
Usage of `assert` is discouraged because it is not evaluated in production code (when `PYOPT=1`). Use `self.assertXY` instead, see `unittest.py`.
33+
34+
## Logging
35+
By default, logging in unittests (using `trezor.log`) is disabled _even_ on debug builds. To enable logging, set `DISABLE_LOG` in `unittest.py` to `False`.

core/tests/test_apps.bitcoin.approver.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ class TestApprover(unittest.TestCase):
3232
if utils.USE_THP:
3333

3434
def setUpClass(self):
35-
if __debug__:
36-
thp_common.suppress_debug_log()
3735
thp_common.prepare_context()
3836

3937
else:

core/tests/test_apps.bitcoin.authorization.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ class TestAuthorization(unittest.TestCase):
2525
if utils.USE_THP:
2626

2727
def setUpClass(self):
28-
if __debug__:
29-
thp_common.suppress_debug_log()
3028
thp_common.prepare_context()
3129

3230
else:

core/tests/test_apps.bitcoin.keychain.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class TestBitcoinKeychain(unittest.TestCase):
2020
if utils.USE_THP:
2121

2222
def setUpClass(self):
23-
if __debug__:
24-
thp_common.suppress_debug_log()
2523
thp_common.prepare_context()
2624

2725
def setUp(self):
@@ -119,8 +117,6 @@ class TestAltcoinKeychains(unittest.TestCase):
119117
if utils.USE_THP:
120118

121119
def setUpClass(self):
122-
if __debug__:
123-
thp_common.suppress_debug_log()
124120
thp_common.prepare_context()
125121

126122
def setUp(self):

core/tests/test_apps.common.keychain.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class TestKeychain(unittest.TestCase):
2424
if utils.USE_THP:
2525

2626
def setUpClass(self):
27-
if __debug__:
28-
thp_common.suppress_debug_log()
2927
thp_common.prepare_context()
3028

3129
else:

core/tests/test_apps.ethereum.keychain.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ def _check_keychain(self, keychain, slip44_id):
8383
if utils.USE_THP:
8484

8585
def setUpClass(self):
86-
if __debug__:
87-
thp_common.suppress_debug_log()
8886
thp_common.prepare_context()
8987

9088
def setUp(self):

core/tests/test_storage.cache.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ class TestStorageCache(unittest.TestCase):
3737

3838
if utils.USE_THP:
3939

40-
def setUpClass(self):
41-
if __debug__:
42-
thp_common.suppress_debug_log()
43-
super().__init__()
44-
4540
def setUp(self):
4641
self.interface = MockHID()
4742
cache.clear_all()

core/tests/test_trezor.wire.thp.crypto.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ class TestTrezorHostProtocolCrypto(unittest.TestCase):
7777
(0xFFFFFFFFFFFFFFFF, b"\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff"),
7878
]
7979

80-
def __init__(self):
81-
if __debug__ and utils.USE_THP:
82-
thp_common.suppress_debug_log()
83-
super().__init__()
84-
8580
def test_encryption(self):
8681
for v in self.vectors_enc:
8782
buffer = bytearray(v[3])

core/tests/test_trezor.wire.thp.writer.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ def await_until_result(self, task: Awaitable) -> Any:
7373
while True:
7474
task.send(None)
7575

76-
def __init__(self):
77-
if __debug__ and utils.USE_THP:
78-
thp_common.suppress_debug_log()
79-
super().__init__()
80-
8176
def setUp(self):
8277
self.interface = MockHID()
8378
thp_ctx = ThpContext(self.interface)

core/tests/thp_common.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,3 @@ def get_new_channel(iface: WireInterface) -> Channel:
2929
thp_ctx = ThpContext(iface)
3030
(iface_ctx,) = thp_ctx._iface_ctxs
3131
return Channel(channel_cache, iface_ctx, (ThpBuffer(), ThpBuffer()))
32-
33-
34-
if __debug__:
35-
# Disable log.debug
36-
def suppress_debug_log() -> None:
37-
from trezor import log
38-
39-
log._min_level = 1

0 commit comments

Comments
 (0)