Commits

Jason R. Coombs  committed 3b7b1e7

Seems rand_bot fails intermittently (because it's random), so run it 100 times for good measure.

  • Participants
  • Parent commits 1969908

Comments (0)

Files changed (2)

File pmxbot/pmxbot.py

 		util.quotes.quoteAdd(quoteToAdd)
 		qt = False
 		return 'Quote added!'
-	else:
-		qt, i, n = util.quotes.quoteLookupWNum(rest)
-		if qt:
-			return '(%s/%s): %s' % (i, n, qt)
+	qt, i, n = util.quotes.quoteLookupWNum(rest)
+	if not qt: return
+	return '(%s/%s): %s' % (i, n, qt)
 
 @command('zinger', aliases=('zing',), doc='ZING!')
 def zinger(client, event, channel, nick, rest):
 		pq.hal, pq.grail, pq.R, pq.anchorman, pq.hangover]
 	func = random.choice(normal_functions + quote_functions)
 	nick = nick if func in normal_functions else ''
+	# save the func for troubleshooting
+	rand_bot.last_func = func
 	return func(client, event, channel, 'pmxbot', nick)
 
 @contains("sqlonrails")

File tests/unit/test_commands.py

 from pmxbot import pmxbot
 from pmxbot import botbase
 
+def pytest_generate_tests(metafunc):
+	# any test that takes the iter_ parameter should be executed 100 times
+	if "iter_" in metafunc.funcargnames:
+		for i in range(100):
+			metafunc.addcall(funcargs=dict(iter_=i))
+
 class Empty(object):
 	"""
 	Passed in to the individual commands instead of a client/event because
 		res = popquotes.pmxbot.bender(c, e, '#test', 'testrunner', '')
 		assert len(res) > 5
 
-	def test_rand_bot(self):
+	def test_rand_bot(self, iter_):
 		res = pmxbot.rand_bot(c, e, '#test', 'testrunner', '')
-		assert len(res) > 5
+		if res is None: return
+		if not isinstance(res, basestring):
+			res = u''.join(res)
+		assert len(res)