Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Add custom coverage test
Browse files Browse the repository at this point in the history
  • Loading branch information
tthijm committed Jun 12, 2024
1 parent 824a293 commit 88c98eb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions discord/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import typing
import warnings
import logging
from cov import test, mark

import yarl

Expand Down Expand Up @@ -1394,15 +1395,20 @@ def _to_kebab_case(text: str) -> str:
return CAMEL_CASE_REGEX.sub('-', text).lower()


@test(4)
def _human_join(seq: Sequence[str], /, *, delimiter: str = ', ', final: str = 'or') -> str:
size = len(seq)
if size == 0:
mark(0)
return ''

if size == 1:
mark(1)
return seq[0]

if size == 2:
mark(2)
return f'{seq[0]} {final} {seq[1]}'

mark(3)
return delimiter.join(seq[:-1]) + f' {final} {seq[-1]}'

0 comments on commit 88c98eb

Please sign in to comment.