testing - python mockito argument captor -


i have been using python mockito https://code.google.com/p/mockito-python/ testing code.

so far python mockito seems provide 2 matchers: contains() , any() https://code.google.com/p/mockito-python/wiki/matchers

i wondering how can write code can capture entire argument.

so example if code

deletesqlstatement = "delete %s lower(z_id)=lower('%s') , y_id=%s" \                          % (self.some_table, zid, yid) cursor.execute(deletesqlstatement) 

currently, can in verification

verify(self.cursor_mock, times=1).execute(contains("delete")) 

it great if can capture entire argument passed execute string.

suggestions?

i guess implement own [matcher] capture argument.

class captor(matcher):    def matches(self, arg):     self.value = arg     return true    def getvalue(self):     return self.value 

and use in test:

captor = captor() verify(self.cursor_mock, times=1).execute(captor) self.assertequal("expected query", captor.getvalue()) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -