def response(self, nick, args, kwargs): testmod = args[0] results = {} for mod_name, obj in self.madcow.modules: if testmod is not None and mod_name != testmod: continue try: test = tests[mod_name] except: continue if not test: continue if isinstance(test, dict): test = [test] passed = True sys.stderr.write('testing %s ... ' % mod_name) for t in test: try: response = '' req = Request(message=t['request']) req.nick = 'test' req.channel = 'test' req.private = True req.sendTo = 'test' req.addressed = True req.colorize = False req.correction = True try: args = obj.pattern.search(req.message).groups() except: print "\n* args didn't match" passed = False break kwargs = {'req': req} kwargs.update(req.__dict__) response = obj.response(req.nick, args, kwargs) if isinstance(t['result'], str): if response != t['result']: passed = False print "\n* string object didn't match" break elif isinstance(t['result'], retype): if t['result'].search(response) is None: passed = False print "\n* regex didn't match" break except Exception, e: print "\n* exception: %s" % e passed = False if passed: sys.stderr.write('ok\r\n') else: sys.stderr.write('fail [%s]\r\n' % repr(response)) results[mod_name] = passed