Increase coverage

This commit is contained in:
stijndcl 2022-07-01 15:46:56 +02:00
parent 9d04d62b1c
commit 27d074d760
9 changed files with 93 additions and 3 deletions

View file

@ -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]

View file

@ -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