2👍
✅
I do not fully understand what causes the exact behaviour you are seeing, especially not why the mock is seemingly working correctly in the first test. But according to the mock docs, you should patch in the namespace under test, i.e. patch("views.tasks")
.
http://www.voidspace.org.uk/python/mock/patch.html#where-to-patch
Source:stackexchange.com