I would like to write a test that will help me determine if the API of the library that I use has changed, for example. after update.
If I created a “blind layout” object, then the layout will always use one method and the tests will pass, but my application will break with the actual library.
I know that there is a way to fix existing objects:
@patch.object(ZipFile, 'namelist')
def test_my_method(self, mocked_zipfile):
which will at least check if the method really namelistexists on the original object, but it still allows me to make a typo when it taunts the object inside:
@patch.object(ZipFile, 'namelist')
def test_my_method(self, mocked_zipfile):
mocked_zipfile.namlist.return_value = [ 'one.txt', 'two.txt' ]
When I make a typo ( namlist) inside the test and inside the test code, the test will just silently pass.
- , , , ( , , )?