mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-10 17:15:47 +02:00
Increase coverage
This commit is contained in:
parent
9d04d62b1c
commit
27d074d760
9 changed files with 93 additions and 3 deletions
|
|
@ -1,3 +1,3 @@
|
|||
def int_to_weekday(number: int) -> str:
|
||||
def int_to_weekday(number: int) -> str: # pragma: no cover # it's useless to write a test for this
|
||||
"""Get the Dutch name of a weekday from the number"""
|
||||
return ["Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"][number]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import math
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def leading(character: str, string: str, target_length: Optional[int] = 2) -> str:
|
||||
"""Add a leading [character] to [string] to make it length [target_length]
|
||||
Pass None to target length to always do it, no matter the length
|
||||
Pass None to target length to always do it (once), no matter the length
|
||||
"""
|
||||
# Cast to string just in case
|
||||
string = str(string)
|
||||
|
|
@ -16,6 +17,6 @@ def leading(character: str, string: str, target_length: Optional[int] = 2) -> st
|
|||
if len(string) >= target_length:
|
||||
return string
|
||||
|
||||
frequency = (target_length - len(string)) // len(character)
|
||||
frequency = math.ceil((target_length - len(string)) / len(character))
|
||||
|
||||
return (frequency * character) + string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue