I'm trying to complete my unit tests for the errbot plugin I am writing. Can anyone tell me how to mock out a helper method which is used by a botcmd
method?
Example:
class ChatBot(BotPlugin):
@classmethod
def mycommandhelper(cls):
return 'This is my awesome commandz'
@botcmd
def mycommand(self, message, args):
return self.mycommandhelper()
How can I mock the mycommandhelper class when executing the my command class? In my case this class is performing some remote operations which should not be executed during unit testing.
After a lot of fiddling around the following seems to work:
Although I believe using patch decorators would be cleaner.