()
| 6 | |
| 7 | |
| 8 | def test_decimal(): |
| 9 | v = SchemaSerializer(core_schema.decimal_schema()) |
| 10 | assert v.to_python(Decimal('123.456')) == Decimal('123.456') |
| 11 | |
| 12 | assert v.to_python(Decimal('123.456'), mode='json') == '123.456' |
| 13 | assert v.to_json(Decimal('123.456')) == b'"123.456"' |
| 14 | |
| 15 | assert v.to_python(Decimal('123456789123456789123456789.123456789123456789123456789')) == Decimal( |
| 16 | '123456789123456789123456789.123456789123456789123456789' |
| 17 | ) |
| 18 | assert ( |
| 19 | v.to_json(Decimal('123456789123456789123456789.123456789123456789123456789')) |
| 20 | == b'"123456789123456789123456789.123456789123456789123456789"' |
| 21 | ) |
| 22 | |
| 23 | with pytest.warns( |
| 24 | UserWarning, |
| 25 | match=r'Expected `decimal` - serialized value may not be as expected \[input_value=123, input_type=int\]', |
| 26 | ): |
| 27 | assert v.to_python(123, mode='json') == 123 |
| 28 | |
| 29 | with pytest.warns( |
| 30 | UserWarning, |
| 31 | match=r'Expected `decimal` - serialized value may not be as expected \[input_value=123, input_type=int\]', |
| 32 | ): |
| 33 | assert v.to_json(123) == b'123' |
| 34 | |
| 35 | |
| 36 | def test_decimal_key(): |
nothing calls this directly
no test coverage detected