mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11: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 short:
|
if i or leadingZeroes or ret:
|
||||||
ret.append('%s%s' % (i, s[0]))
|
if short:
|
||||||
else:
|
ret.append('%s%s' % (i, s[0]))
|
||||||
if leadingZeroes or ret or i:
|
else:
|
||||||
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