From afc3c3f94a15326d96f43715055ac54c255a2f3e Mon Sep 17 00:00:00 2001 From: James Vega Date: Mon, 31 Jan 2005 15:59:44 +0000 Subject: [PATCH] Fix some calls to pluralize to not use the extra argument. Also updated the pluralize tests. --- src/utils/str.py | 10 ++++++++-- test/test_utils.py | 21 +++++++-------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/utils/str.py b/src/utils/str.py index b3a31bdd6..3dc294f74 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -299,9 +299,15 @@ def nItems(n, item, between=None): assert isinstance(n, int), \ 'The order of the arguments to nItems changed again, sorry.' if between is None: - return '%s %s' % (n, pluralize(item, n)) + if n > 1: + return format('%s %p', n, item) + else: + return format('%s %s', n, item) else: - return '%s %s %s' % (n, between, pluralize(item, n)) + if n > 1: + return format('%s %s %p', n, between, item) + else: + return format('%s %s %s', n, between, item) def be(i): """Returns the form of the verb 'to be' based on the number i.""" diff --git a/test/test_utils.py b/test/test_utils.py index 42bff17e3..ae86fd64d 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -169,20 +169,13 @@ class StrTest(SupyTestCase): def testPluralize(self): f = utils.str.pluralize - self.assertEqual('bike', f('bike', 1)) - self.assertEqual('bikes', f('bike', 2)) - self.assertEqual('BIKE', f('BIKE', 1)) - self.assertEqual('BIKES', f('BIKE', 2)) - self.assertEqual('match', f('match', 1)) - self.assertEqual('matches', f('match', 2)) - self.assertEqual('Patch', f('Patch', 1)) - 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)) + self.assertEqual('bikes', f('bike')) + self.assertEqual('BIKES', f('BIKE')) + self.assertEqual('matches', f('match')) + self.assertEqual('Patches', f('Patch')) + self.assertEqual('fishes', f('fish')) + self.assertEqual('tries', f('try')) + self.assertEqual('days', f('day')) def testDepluralize(self): f = utils.str.depluralize