mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-25 19:44:13 +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:
|
elif len(L) == 2:
|
||||||
return '%s and %s' % (L[0], L[1])
|
return '%s and %s' % (L[0], L[1])
|
||||||
else:
|
else:
|
||||||
|
# Not technically threadsafe. But we'll see if that matters.
|
||||||
|
originalLastElement = L[-1]
|
||||||
L[-1] = 'and %s' % 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:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
@ -134,11 +134,17 @@ class UtilsTest(unittest.TestCase):
|
|||||||
|
|
||||||
def testCommaAndify(self):
|
def testCommaAndify(self):
|
||||||
L = ['foo']
|
L = ['foo']
|
||||||
|
original = L[:]
|
||||||
self.assertEqual(utils.commaAndify(L), 'foo')
|
self.assertEqual(utils.commaAndify(L), 'foo')
|
||||||
|
self.assertEqual(L, original)
|
||||||
L.append('bar')
|
L.append('bar')
|
||||||
|
original = L[:]
|
||||||
self.assertEqual(utils.commaAndify(L), 'foo and bar')
|
self.assertEqual(utils.commaAndify(L), 'foo and bar')
|
||||||
|
self.assertEqual(L, original)
|
||||||
L.append('baz')
|
L.append('baz')
|
||||||
|
original = L[:]
|
||||||
self.assertEqual(utils.commaAndify(L), 'foo, bar, and baz')
|
self.assertEqual(utils.commaAndify(L), 'foo, bar, and baz')
|
||||||
|
self.assertEqual(L, original)
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user