-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0678809
commit e611d9e
Showing
3 changed files
with
39 additions
and
9 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 |
---|---|---|
@@ -1,5 +1,27 @@ | ||
from datetime import datetime | ||
from typing import Any | ||
|
||
from cloudrunfastapi.logger import logger | ||
|
||
|
||
def test_logger() -> None: | ||
def test_logger(capsys: Any) -> None: | ||
logger.exception("this is an exception") | ||
|
||
logger.info( | ||
"testing types", | ||
extra={ | ||
"string": "string", | ||
"bytes": b"test", | ||
"set": {"test", "test2"}, | ||
"time": datetime.now(), | ||
}, | ||
) | ||
|
||
class MyUnsupportedType: | ||
def __init__(self, data: str) -> None: | ||
self.data = data | ||
|
||
logger.info("testing types", extra={"random": MyUnsupportedType("test")}) | ||
out, err = capsys.readouterr() | ||
assert out == "" | ||
assert "TypeError: Object of type MyUnsupportedType is not JSON serializable" in err |