Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nhairs committed Apr 30, 2024
1 parent 0ee6b9a commit ab895ec
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
19 changes: 19 additions & 0 deletions tests/test_deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### IMPORTS
### ============================================================================
## Future
from __future__ import annotations

## Standard Library

## Installed
import pytest

## Application
import pythonjsonlogger

### TESTS
### ============================================================================
def test_jsonlogger_deprecated():
with pytest.deprecated_call():
pythonjsonlogger.jsonlogger
return
14 changes: 12 additions & 2 deletions tests/test_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

## Application
import pythonjsonlogger
from pythonjsonlogger.core import RESERVED_ATTRS, BaseJsonFormatter
from pythonjsonlogger.core import RESERVED_ATTRS, BaseJsonFormatter, merge_record_extra
from pythonjsonlogger.json import JsonFormatter

if pythonjsonlogger.ORJSON_AVAILABLE:
Expand Down Expand Up @@ -79,7 +79,17 @@ def get_traceback_from_exception_followed_by_log_call(env_: LoggingEnvironment)

### TESTS
### ============================================================================
## Common Tests
def test_merge_record_extra():
record = logging.LogRecord(
"name", level=1, pathname="", lineno=1, msg="Some message", args=None, exc_info=None
)
output = merge_record_extra(record, target={"foo":"bar"}, reserved=[])
assert output["foo"] == "bar"
assert output["msg"] == "Some message"
return


## Common Formatter Tests
## -----------------------------------------------------------------------------
@pytest.mark.parametrize("class_", ALL_FORMATTERS)
def test_default_format(env: LoggingEnvironment, class_: type[BaseJsonFormatter]):
Expand Down
24 changes: 0 additions & 24 deletions tests/test_jsonlogger.py

This file was deleted.

0 comments on commit ab895ec

Please sign in to comment.