Fix for a bug in the short timeElapsed.

This commit is contained in:
Jeremy Fincher 2004-12-08 20:27:59 +00:00
parent f1cbd065f3
commit 5466544350
2 changed files with 7 additions and 4 deletions

View File

@ -127,10 +127,10 @@ def timeElapsed(elapsed, short=False, leadingZeroes=False, years=True,
"""
ret = []
def format(s, i):
if short:
ret.append('%s%s' % (i, s[0]))
else:
if leadingZeroes or ret or i:
if i or leadingZeroes or ret:
if short:
ret.append('%s%s' % (i, s[0]))
else:
ret.append(nItems(s, i))
elapsed = int(elapsed)
assert years or weeks or days or \

View File

@ -98,6 +98,9 @@ class UtilsTest(SupyTestCase):
'and 2 seconds')]:
self.assertEqual(utils.timeElapsed(now - then), expected)
def timeElapsedShort(self):
self.assertEqual(utils.timeElapsed(123, short=True), '2m 3s')
def testEachSubstring(self):
s = 'foobar'
L = ['f', 'fo', 'foo', 'foob', 'fooba', 'foobar']