Hello guys,
class MyClass:
def foo(self):
items = ["A"]
self.bar(items)
items.append("B")
print(items)
def bar(self, items):
pass
class MyTest(unittest.TestCase):
def test_MyClass(self):
with patch.object(MyClass, "bar") as mock_bar:
obj = MyClass()
obj.foo()
mock_bar.assert_called_once_with(["A", "B"])
This test succeeds but it shouldn't. mock_bar was called with a list of only one item, not a list of two items. I had expected the assert_called_once_with does a deep test (checking the content of the items).
Is there any way to know, when the mock / method was called, how the actual content looked like?
Thanks!
Aucun commentaire:
Enregistrer un commentaire