I'm building a bunch of tests and discovered that some of them are failing when they are all run together. Looking at why they are breaking I discovered it is because we memoize some of the system calls for the setup.
Because I'm mocking the system calls and not the memoized the function is only computed once and so it leaks that information into the subsequent tests.
What is the elegant way to deal with memoized functions:
Any other ideas ?
Thanks
Maybe it's too late but I found very easy to use delete_memoized:
# your function
@memoize(timeout=50)
def your_long_function():
# do stuff
# your test
def test_get_folder_content_error_handled(self, flf):
delete_memoized(your_long_function)
your_long_function()
I just used this solution in Django (using django-memoize) and it works like a charm!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With