DEV Community

Discussion on: Python unit testing with Mock - Part One

Collapse
 
mistermocha profile image
mistermocha

Interesting ... although the article you post doesn't indicate that the decorator causes problems, but improper use of return values in the decorator is what causes the leaks.

I'm certainly doing this in my example, and I wasn't aware that it caused this problem. I've been writing tests for years and hadn't known about this. Thanks so much for sharing!

Collapse
 
s0undt3ch profile image
Pedro Algarvio

Yes, the wrong usage of return values are the issue that cause leakage.

As far as running into trouble, unless you have a massive amount of tests, you won't actually run out of memory, so, like you, probably 99% of mock users won't hit any issues, but its worth keeping that article in your mind if you see some weird behavior on your tests.