mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Fix for a bug in the short timeElapsed.
This commit is contained in:
parent
f1cbd065f3
commit
5466544350
@ -127,10 +127,10 @@ def timeElapsed(elapsed, short=False, leadingZeroes=False, years=True,
|
|||||||
"""
|
"""
|
||||||
ret = []
|
ret = []
|
||||||
def format(s, i):
|
def format(s, i):
|
||||||
|
if i or leadingZeroes or ret:
|
||||||
if short:
|
if short:
|
||||||
ret.append('%s%s' % (i, s[0]))
|
ret.append('%s%s' % (i, s[0]))
|
||||||
else:
|
else:
|
||||||
if leadingZeroes or ret or i:
|
|
||||||
ret.append(nItems(s, i))
|
ret.append(nItems(s, i))
|
||||||
elapsed = int(elapsed)
|
elapsed = int(elapsed)
|
||||||
assert years or weeks or days or \
|
assert years or weeks or days or \
|
||||||
|
@ -98,6 +98,9 @@ class UtilsTest(SupyTestCase):
|
|||||||
'and 2 seconds')]:
|
'and 2 seconds')]:
|
||||||
self.assertEqual(utils.timeElapsed(now - then), expected)
|
self.assertEqual(utils.timeElapsed(now - then), expected)
|
||||||
|
|
||||||
|
def timeElapsedShort(self):
|
||||||
|
self.assertEqual(utils.timeElapsed(123, short=True), '2m 3s')
|
||||||
|
|
||||||
def testEachSubstring(self):
|
def testEachSubstring(self):
|
||||||
s = 'foobar'
|
s = 'foobar'
|
||||||
L = ['f', 'fo', 'foo', 'foob', 'fooba', 'foobar']
|
L = ['f', 'fo', 'foo', 'foob', 'fooba', 'foobar']
|
||||||
|
Loading…
Reference in New Issue
Block a user