I'm doing a number of unit tests in a row, and between each one, the class_registry object maintains. This is as intended when the app is running, but not so when just running unit tests.
Is there a best practice for wiping the class_registry? Or for just removing all registered objects since the class was created?
.. warning::
This module is treated as private API.
Users should not need to use this module directly.
https://marshmallow.readthedocs.io/en/stable/api_reference.html#module-marshmallow.class_registry
It doesn't look like this use case has been considered before. Is there a specific side effect this is causing in your tests?
This code hasn't changed in the last 6 years, so it's probably safe to just marshmallow.class_registry._registry.clear() in your tests.
I agree with @deckar01 's suggestion. The warning in the docs is moreso to avoid us from having to consider API changes to class_registry a breaking change, but the reality is that module really shouldn't change very often.
Most helpful comment
https://marshmallow.readthedocs.io/en/stable/api_reference.html#module-marshmallow.class_registry
It doesn't look like this use case has been considered before. Is there a specific side effect this is causing in your tests?
This code hasn't changed in the last 6 years, so it's probably safe to just
marshmallow.class_registry._registry.clear()in your tests.