test_irclib: Make use of context for maxHistoryLength.

This commit is contained in:
Valentin Lorentz 2012-12-27 11:05:04 +00:00
parent 499d68f73a
commit 6b7db2e9f1

View File

@ -1,4 +1,4 @@
### ##
# Copyright (c) 2002-2005, Jeremiah Fincher # Copyright (c) 2002-2005, Jeremiah Fincher
# All rights reserved. # All rights reserved.
# #
@ -261,9 +261,7 @@ class IrcStateTestCase(SupyTestCase):
if len(msgs) < 10: if len(msgs) < 10:
return return
maxHistoryLength = conf.supybot.protocols.irc.maxHistoryLength maxHistoryLength = conf.supybot.protocols.irc.maxHistoryLength
oldconfmaxhistory = maxHistoryLength() with maxHistoryLength.context(10):
try:
maxHistoryLength.setValue(10)
state = irclib.IrcState() state = irclib.IrcState()
for msg in msgs: for msg in msgs:
try: try:
@ -274,8 +272,6 @@ class IrcStateTestCase(SupyTestCase):
self.assertEqual(len(state.history), maxHistoryLength()) self.assertEqual(len(state.history), maxHistoryLength())
self.assertEqual(list(state.history), self.assertEqual(list(state.history),
msgs[len(msgs) - maxHistoryLength():]) msgs[len(msgs) - maxHistoryLength():])
finally:
maxHistoryLength.setValue(oldconfmaxhistory)
def testWasteland005(self): def testWasteland005(self):
state = irclib.IrcState() state = irclib.IrcState()