Skip to content

Commit a7f8199

Browse files
author
Tom McCarthy
committed
chore: add test for unhandled types
1 parent a3cdef8 commit a7f8199

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/unit/test_json_encoder.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import decimal
22
import json
33

4+
import pytest
5+
46
from aws_lambda_powertools.shared.json_encoder import Encoder
57

68

@@ -12,3 +14,11 @@ def test_jsonencode_decimal():
1214
def test_jsonencode_decimal_nan():
1315
result = json.dumps({"val": decimal.Decimal("NaN")}, cls=Encoder)
1416
assert result == '{"val": NaN}'
17+
18+
19+
def test_jsonencode_calls_default():
20+
class CustomClass:
21+
pass
22+
23+
with pytest.raises(TypeError):
24+
json.dumps({"val": CustomClass()}, cls=Encoder)

0 commit comments

Comments
 (0)