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
FrankLawrence committed Jun 12, 2024
1 parent dc892c7 commit 45156c5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion discord/colour.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import colorsys
import random
import re
from cov import test, mark

from typing import TYPE_CHECKING, Optional, Tuple, Union

Expand All @@ -51,17 +52,22 @@ def parse_hex_number(argument: str) -> Colour:
else:
return Color(value=value)


@test(5)
def parse_rgb_number(number: str) -> int:
if number[-1] == '%':
mark(0)
value = float(number[:-1])
if not (0 <= value <= 100):
mark(1)
raise ValueError('rgb percentage can only be between 0 to 100')
mark(2)
return round(255 * (value / 100))

value = int(number)
if not (0 <= value <= 255):
mark(3)
raise ValueError('rgb number can only be between 0 to 255')
mark(4)
return value


Expand Down

0 comments on commit 45156c5

Please sign in to comment.