mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Ew, modified the original argument in utils.commaAndify.
This commit is contained in:
parent
89e4a3ea59
commit
4858770ee7
@ -267,7 +267,11 @@ def commaAndify(L):
|
||||
elif len(L) == 2:
|
||||
return '%s and %s' % (L[0], L[1])
|
||||
else:
|
||||
# Not technically threadsafe. But we'll see if that matters.
|
||||
originalLastElement = L[-1]
|
||||
L[-1] = 'and %s' % L[-1]
|
||||
return ', '.join(L)
|
||||
s = ', '.join(L)
|
||||
L[-1] = originalLastElement
|
||||
return s
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
@ -134,11 +134,17 @@ class UtilsTest(unittest.TestCase):
|
||||
|
||||
def testCommaAndify(self):
|
||||
L = ['foo']
|
||||
original = L[:]
|
||||
self.assertEqual(utils.commaAndify(L), 'foo')
|
||||
self.assertEqual(L, original)
|
||||
L.append('bar')
|
||||
original = L[:]
|
||||
self.assertEqual(utils.commaAndify(L), 'foo and bar')
|
||||
self.assertEqual(L, original)
|
||||
L.append('baz')
|
||||
original = L[:]
|
||||
self.assertEqual(utils.commaAndify(L), 'foo, bar, and baz')
|
||||
self.assertEqual(L, original)
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user