Skip to content

Commit e453b14

Browse files
committed
enable caplog for loguru
1 parent 6ae1eff commit e453b14

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import logging
12
import pytest
3+
from _pytest.logging import caplog as _caplog
24
from pythclient.solana import SolanaClient
5+
from loguru import logger
36

47

58
@pytest.fixture
@@ -8,3 +11,13 @@ def solana_client():
811
endpoint="https://example.com",
912
ws_endpoint="wss://example.com",
1013
)
14+
15+
@pytest.fixture
16+
def caplog(_caplog):
17+
class PropogateHandler(logging.Handler):
18+
def emit(self, record):
19+
logging.getLogger(record.name).handle(record)
20+
21+
handler_id = logger.add(PropogateHandler(), format="{message}")
22+
yield _caplog
23+
logger.remove(handler_id)

0 commit comments

Comments
 (0)