called_with is not a real test method on MagicMock, so it returns a MagicMock instance by default, which is truthy and evaluates to true.
Tests using this method assert MagicMock().called_with() are essentially running assert MagicMock() which is the same as assert True. These tests aren't checking for anything and pass no matter what actually happens in the code.
The documentation on how to write tests incorrectly advocates using this syntax:
called_with
is not a real test method on MagicMock, so it returns a MagicMock instance by default, which is truthy and evaluates to true.Tests using this method
assert MagicMock().called_with()
are essentially runningassert MagicMock()
which is the same asassert True
. These tests aren't checking for anything and pass no matter what actually happens in the code.The documentation on how to write tests incorrectly advocates using this syntax: