Fix Python 2.6 compatibility.

This commit is contained in:
Valentin Lorentz 2014-07-31 19:53:00 +00:00
parent 0f174d9ee0
commit c6cb948996
2 changed files with 5 additions and 5 deletions

View File

@ -374,7 +374,7 @@ registerChannelValue(supybot.reply.format, 'time',
def timestamp(t): def timestamp(t):
if t is None: if t is None:
t = time.time() t = time.time()
elif isinstance(t, float) or isinstance(t, int): if isinstance(t, float) or isinstance(t, int):
t = time.localtime(t) t = time.localtime(t)
format = get(supybot.reply.format.time, dynamic.channel) format = get(supybot.reply.format.time, dynamic.channel)
return time.strftime(format, t) return time.strftime(format, t)

View File

@ -1136,7 +1136,7 @@ class TestCacheDict(SupyTestCase):
class TestTruncatableSet(SupyTestCase): class TestTruncatableSet(SupyTestCase):
def testBasics(self): def testBasics(self):
s = TruncatableSet(['foo', 'bar', 'baz', 'qux']) s = TruncatableSet(['foo', 'bar', 'baz', 'qux'])
self.assertEqual(s, {'foo', 'bar', 'baz', 'qux'}) self.assertEqual(s, set(['foo', 'bar', 'baz', 'qux']))
self.failUnless('foo' in s) self.failUnless('foo' in s)
self.failUnless('bar' in s) self.failUnless('bar' in s)
self.failIf('quux' in s) self.failIf('quux' in s)
@ -1151,13 +1151,13 @@ class TestTruncatableSet(SupyTestCase):
s.add('baz') s.add('baz')
s.add('qux') s.add('qux')
s.truncate(3) s.truncate(3)
self.assertEqual(s, {'bar', 'baz', 'qux'}) self.assertEqual(s, set(['bar', 'baz', 'qux']))
def testTruncateUnion(self): def testTruncateUnion(self):
s = TruncatableSet(['bar', 'foo']) s = TruncatableSet(['bar', 'foo'])
s |= {'baz', 'qux'} s |= set(['baz', 'qux'])
s.truncate(3) s.truncate(3)
self.assertEqual(s, {'foo', 'baz', 'qux'}) self.assertEqual(s, set(['foo', 'baz', 'qux']))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: