Skip to content

Commit

Permalink
chore: add test for unhandled types
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom McCarthy committed Feb 20, 2021
1 parent a3cdef8 commit a7f8199
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/unit/test_json_encoder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import decimal
import json

import pytest

from aws_lambda_powertools.shared.json_encoder import Encoder


Expand All @@ -12,3 +14,11 @@ def test_jsonencode_decimal():
def test_jsonencode_decimal_nan():
result = json.dumps({"val": decimal.Decimal("NaN")}, cls=Encoder)
assert result == '{"val": NaN}'


def test_jsonencode_calls_default():
class CustomClass:
pass

with pytest.raises(TypeError):
json.dumps({"val": CustomClass()}, cls=Encoder)

0 comments on commit a7f8199

Please sign in to comment.