Why do we need the func=None parameter, if the original method does not receive any paramter? Why are we storing the func value, if then we're just passing None and testing against it?
Also, the self._called = self has no much sense as well, as far as I can see.
If I understand the fake correctly, I think this is a simpler option:
So, perhaps I was not clear before... but I still see no point in having this patched connect_files method:
def connect_files(self, func=None):
self.propertie s['connect_ files_called' ] = True
self.propertie s['connect_ files'] = func
"""Fake connect_files"""
Why do we need the func=None parameter, if the original method does not receive any paramter? Why are we storing the func value, if then we're just passing None and testing against it?
Also, the self._called = self has no much sense as well, as far as I can see.
If I understand the fake correctly, I think this is a simpler option:
class FakeBackend( object) :
"""Fake ControlBackend."""
def __init__(self, *args, **kwargs):
self.connect_ files = lambda: self.called. append( 'connect_ files')
self.called = []
self.clear = lambda: None
and have the test only test for assertEqual(called, ['connect_files']).