diff --git a/humanfriendly/tests.py b/humanfriendly/tests.py index 4e8c019..6fb9b26 100644 --- a/humanfriendly/tests.py +++ b/humanfriendly/tests.py @@ -4,7 +4,7 @@ # Tests for the `humanfriendly' package. # # Author: Peter Odding -# Last Change: April 19, 2020 +# Last Change: November 30, 2020 # URL: https://humanfriendly.readthedocs.io """Test suite for the `humanfriendly` package.""" @@ -441,7 +441,7 @@ def test_format_timespan(self): # Make sure milliseconds are never shown separately when detailed=False. # https://github.com/xolox/python-humanfriendly/issues/10 assert '1 minute, 1 second and 100 milliseconds' == format_timespan(61.10, detailed=True) - assert '1 minute and 1.1 second' == format_timespan(61.10, detailed=False) + assert '1 minute and 1.1 seconds' == format_timespan(61.10, detailed=False) # Test for loss of precision as reported in issue 11: # https://github.com/xolox/python-humanfriendly/issues/11 assert '1 minute and 0.3 seconds' == format_timespan(60.300) diff --git a/humanfriendly/text.py b/humanfriendly/text.py index a5a39e1..15396a2 100644 --- a/humanfriendly/text.py +++ b/humanfriendly/text.py @@ -1,7 +1,7 @@ # Human friendly input/output in Python. # # Author: Peter Odding -# Last Change: March 1, 2020 +# Last Change: November 30, 2020 # URL: https://humanfriendly.readthedocs.io """ @@ -20,7 +20,6 @@ """ # Standard library modules. -import math import numbers import random import re @@ -284,11 +283,11 @@ def pluralize(count, singular, plural=None): :param count: The count (a number). :param singular: The singular form of the word (a string). :param plural: The plural form of the word (a string or :data:`None`). - :returns: The count and singular/plural word concatenated (a string). + :returns: The count and singular or plural word concatenated (a string). """ if not plural: plural = singular + 's' - return '%s %s' % (count, singular if math.floor(float(count)) == 1 else plural) + return '%s %s' % (count, singular if float(count) == 1.0 else plural) def random_string(length=(25, 100), characters=string.ascii_letters):