Add random_color and the color palette

random_color returns an immutable (red, green, blue) tuple of integers from 0 to 255
and random_palette_color picks a named color. Both take an optional random.Random
so that tests can seed them.

Task: MIL-003#1
Task: MIL-003#2
This commit is contained in:
2026-10-07 23:59:02 +08:00
parent b3153b9dc1
commit 9318a07fa0
5 changed files with 127 additions and 0 deletions
+9
View File
@@ -1,5 +1,14 @@
from turtle_challenges import constants
def test_color_mode_matches_the_largest_channel_value() -> None:
assert constants.COLOR_MODE == constants.COLOR_CHANNEL_MAX == 255
def test_challenge_names_are_unique() -> None:
assert len(set(constants.CHALLENGE_NAMES)) == len(constants.CHALLENGE_NAMES)
def test_palette_has_only_non_empty_names() -> None:
assert constants.COLOR_PALETTE
assert all(name for name in constants.COLOR_PALETTE)