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!
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
mock.patch
should preferably be used in awith
statement as opposed to using it as a test function decorator.Here's some more insight on why.
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!
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.