-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add test for request error logs
- Loading branch information
1 parent
e8a5438
commit 45ba9fb
Showing
4 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from pytest import fixture | ||
from logging import getLogger, Logger, Handler, LogRecord | ||
|
||
|
||
class LogHandler(Handler): | ||
def __init__(self): | ||
super().__init__() | ||
self._logs = [] | ||
|
||
|
||
def emit(self, record): | ||
self._logs.append(record) | ||
|
||
|
||
def get_logs(self) -> list[LogRecord]: | ||
return self._logs | ||
|
||
|
||
@fixture | ||
def test_log_handler() -> LogHandler: | ||
return LogHandler() | ||
|
||
|
||
@fixture | ||
def test_logger(test_log_handler) -> Logger: | ||
logger = getLogger('paddle_test_logger') | ||
logger.addHandler(test_log_handler) | ||
return logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from tests.Utils.TestClient import mock_requests, test_client | ||
from tests.Utils.TestLogger import test_log_handler, test_logger |