You need to change the assertion to look for mock_Blob.from_connection_string.return_value.get_container_client.assert_called_once() -- note the added .return_value. get_container_client is an attribute of the mock returned by calling from_connection_string, it's not an attribute of from_connection_string.
Note that your debug prints also confirm this; the calls are recorded on from_connection_string().get_container_client(...) (note the parentheses); when you print mock_Blob.from_connection_string.get_container_client.mock_calls it is (correctly) empty.
armartirosyan commentedDec 21, 2022
Bug report
Nested method fails assertion. More details are in the
Environment
sectionEnvironment
Files
$ tree . ├── module.py └── test_azure_blob.py
module.py
test_azure_blob.py
When tested assertion fails. Traceback is below
As the prints are showing, the
MagicMock
identified that theget_container_client
nested method was called, but the actual call fails the assertion.The text was updated successfully, but these errors were encountered: