Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions humanfriendly/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,10 @@ def test_concatenate(self):
# Test the 'conjunction' option.
assert concatenate(['one', 'two', 'three'], conjunction='or') == 'one, two or three'
# Test the 'serial_comma' option.
assert concatenate([], serial_comma=True) == ''
assert concatenate(['one'], serial_comma=True) == 'one'
assert concatenate(['one', 'two'], serial_comma=True) == 'one and two'
assert concatenate(iter(['one', 'two']), conjunction='or', serial_comma=True) == 'one or two'
assert concatenate(['one', 'two', 'three'], serial_comma=True) == 'one, two, and three'

def test_split(self):
Expand Down
2 changes: 1 addition & 1 deletion humanfriendly/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def concatenate(items, conjunction='and', serial_comma=False):
if len(items) > 1:
final_item = items.pop()
formatted = ', '.join(items)
if serial_comma:
if serial_comma and len(items) > 1:
formatted += ','
return ' '.join([formatted, conjunction, final_item])
elif items:
Expand Down