Fix some calls to pluralize to not use the extra argument. Also updated the pluralize tests.

This commit is contained in:
James Vega 2005-01-31 15:59:44 +00:00
parent 4b4bfa0abe
commit afc3c3f94a
2 changed files with 15 additions and 16 deletions

View File

@ -299,9 +299,15 @@ def nItems(n, item, between=None):
assert isinstance(n, int), \ assert isinstance(n, int), \
'The order of the arguments to nItems changed again, sorry.' 'The order of the arguments to nItems changed again, sorry.'
if between is None: if between is None:
return '%s %s' % (n, pluralize(item, n)) if n > 1:
return format('%s %p', n, item)
else: else:
return '%s %s %s' % (n, between, pluralize(item, n)) return format('%s %s', n, item)
else:
if n > 1:
return format('%s %s %p', n, between, item)
else:
return format('%s %s %s', n, between, item)
def be(i): def be(i):
"""Returns the form of the verb 'to be' based on the number i.""" """Returns the form of the verb 'to be' based on the number i."""

View File

@ -169,20 +169,13 @@ class StrTest(SupyTestCase):
def testPluralize(self): def testPluralize(self):
f = utils.str.pluralize f = utils.str.pluralize
self.assertEqual('bike', f('bike', 1)) self.assertEqual('bikes', f('bike'))
self.assertEqual('bikes', f('bike', 2)) self.assertEqual('BIKES', f('BIKE'))
self.assertEqual('BIKE', f('BIKE', 1)) self.assertEqual('matches', f('match'))
self.assertEqual('BIKES', f('BIKE', 2)) self.assertEqual('Patches', f('Patch'))
self.assertEqual('match', f('match', 1)) self.assertEqual('fishes', f('fish'))
self.assertEqual('matches', f('match', 2)) self.assertEqual('tries', f('try'))
self.assertEqual('Patch', f('Patch', 1)) self.assertEqual('days', f('day'))
self.assertEqual('Patches', f('Patch', 2))
self.assertEqual('fish', f('fish', 1))
self.assertEqual('fishes', f('fish', 2))
self.assertEqual('try', f('try', 1))
self.assertEqual('tries', f('try', 2))
self.assertEqual('day', f('day', 1))
self.assertEqual('days', f('day', 2))
def testDepluralize(self): def testDepluralize(self):
f = utils.str.depluralize f = utils.str.depluralize