question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Marshmallow's default values are not changed by Freezegun

See original GitHub issue

Minimal 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:open
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
boxedcommented, Oct 12, 2020

Yes, nested freezes is a big part of the API! With a global freeze you can also simplify your tests quite a bit.

0reactions
egor83commented, Oct 12, 2020

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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Marshmallow Field not loading default value - Stack Overflow
Until marshmallow 3.12: default : value to use by default when dumping (serializing); missing : value to use by default when loading ...
Read more >
freezegun - PyPI
FreezeGun is a library that allows your Python tests to travel through time by ... no guarantees about their absolute value, only their...
Read more >
python/typing - Gitter
Hello! I'm debugging marshmallow-code/marshmallow#1442 and I am doing some research before opening a mypy issue. I am looking into how Union types get...
Read more >
What's New - Oracle Linux Yum Server
xfce4-settings-4.16.5-2.el8 - Settings Manager for Xfce (Update) ... Immutable collection datatypes (the fast but not thread safe version) (New) ...
Read more >
Package List — Spack 0.20.0.dev0 documentation
The tuned implementations of industry standard math libraries enable fast ... taking advantage of libFLAME with virtually no changes to their source code....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found