mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 23:55:46 +02:00
Increase coverage a bit
This commit is contained in:
parent
88bbb9773f
commit
ac24688a73
5 changed files with 56 additions and 2 deletions
|
|
@ -1,4 +1,23 @@
|
|||
from didier.utils.types.string import leading
|
||||
from didier.utils.types.string import abbreviate, leading, pluralize
|
||||
|
||||
|
||||
def test_abbreviate_under_max_length():
|
||||
"""Test abbreviate() when the input text is shorter than the max length"""
|
||||
text = "TEST STRING"
|
||||
assert abbreviate(text, max_length=len(text)) == text
|
||||
assert abbreviate(text, max_length=len(text) + 1) == text
|
||||
|
||||
|
||||
def test_abbreviate_longer():
|
||||
"""Test abbreviate() when the input text is longer than the max length"""
|
||||
text = "TEST STRING"
|
||||
assert abbreviate(text, max_length=7) == "TEST S…"
|
||||
|
||||
|
||||
def test_abbreviate_whitespace():
|
||||
"""Test abbreviate() when the max length would end on whitespace"""
|
||||
text = "TEST STRING"
|
||||
assert abbreviate(text, max_length=6) == "TEST…"
|
||||
|
||||
|
||||
def test_leading():
|
||||
|
|
@ -20,3 +39,22 @@ def test_leading_no_exact():
|
|||
def test_leading_no_target_length():
|
||||
"""Test leading() when target_length is None"""
|
||||
assert leading("0", "05", target_length=None) == "005"
|
||||
|
||||
|
||||
def test_pluralize_singular():
|
||||
"""Test pluralize() when the word is singular"""
|
||||
word = "word"
|
||||
assert pluralize(word, amount=1, plural_form="whatever") == word
|
||||
|
||||
|
||||
def test_pluralize_plural_default():
|
||||
"""Test pluralize() for the default plural form (+s)"""
|
||||
word = "word"
|
||||
assert pluralize(word, amount=2) == "words"
|
||||
|
||||
|
||||
def test_pluralize_custom_plural():
|
||||
"""Test pluralize() when a custom plural form is provided"""
|
||||
word = "word"
|
||||
plural = "plural"
|
||||
assert pluralize(word, amount=2, plural_form=plural) == plural
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue