Marshmallow's default values are not changed by Freezegun
See original GitHub issueMinimal reproducible example:
app_stub/__init__.py: https://pastebin.com/TYbyBhwL
app_stub/serializers.py: https://pastebin.com/vNS9aAuj
tests/conftest.py: https://pastebin.com/kqia2pKH
tests/test_stub.py https://pastebin.com/SVxty54j
Run test with pytest
.
Or I could send you a zip file if you give me an email address.
I would expect Marshmallow’s default values to be set to Freezegun’s time (so that both printed values are the same), but it uses real time instead. At a glance, it seems to happen because Marshmallow’s default value is (evaluated? loaded?) during test setup, and not during test execution, so probably before Freezegun comes into play - you can check this if you uncomment exception throwing in Marshmallow’s default function.
That said - thanks a lot for Freezegun, it’s been a great help for us!
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Yes, nested freezes is a big part of the API! With a global freeze you can also simplify your tests quite a bit.
I’ve just checked - further freezes override the first one, so global freeze indeed looks like a good solution (we just already have a ton of tests using Freezegun, so if global freeze would break these, it’d be a hassle - but it’s not what happens).