|
|
|
|
|
by f00_
1916 days ago
|
|
assert on the call_count attribute of a mock instead of trying to use methods on it like .assert_called_once_with() "a mock’s job is to say, “You got it, boss” whenever anyone calls it. It will do real work, like raising an exception, when one of its convenience methods is called, like assert_called_once_with. But it won’t do real work when you call a method that only resembles a convenience method, such as assert_called_once (no _with!)." https://engineeringblog.yelp.com/2015/02/assert_called_once-... |
|
When unsafe=False (the default), accessing an attribute that begins with assert will raise an error.
[1]: https://docs.python.org/3/library/unittest.mock.html#the-moc...