Closed lafrech closed 6 months ago
@lafrech the reason the test fails, is because that value is generated here: https://github.com/ddorian/apispec/blob/e4e962b08b351caa655fe93045bbe01db4e3582e/src/apispec/ext/marshmallow/field_converter.py#L227
That calls fields.Decimal.serialize()
which returns a Decimal.
Why were you expecting to return a float? Which is non-exact data type.
At most you would expect it to return a string, which would work, by setting dec = ma.fields.Decimal(load_default=Decimal("0.5"), as_string=True)
.
At that code, it's not connected at all to app.json = ...
, it's no json-conversion at all inside the test.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.88%. Comparing base (
5021607
) to head (b00c8d2
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
The reason the tests failed was because I tested the type in the output of spec.to_dict
, before actually serializing to JSON... This is fixed.
In the meantime, Decimal
support was added to flask
default JSON encoder, so I rewrote the test to serialize a dummy custom type.
Fixes #517.
Ping @kaibr.
I need to figure out why tests don't pass. Opening a PR to avoid forgetting about it again.
(Wondering if we should subclass
DefaultJSONProvider
in the test. It wouldn't matter for the test but for example sake.)