Skip to content

Add unit tests for color scheme logic (get_player_color, color_definitions, generate_legend)#61

Open
ravjot07 wants to merge 1 commit intogambitproject:mainfrom
ravjot07:fix/color-logic-tests
Open

Add unit tests for color scheme logic (get_player_color, color_definitions, generate_legend)#61
ravjot07 wants to merge 1 commit intogambitproject:mainfrom
ravjot07:fix/color-logic-tests

Conversation

@ravjot07
Copy link
Copy Markdown

Summary

This PR adds a dedicated test module, tests/test_color_schemes.py, so the package’s color behavior is covered by automated tests instead of relying only on implicit coverage through broader draw-tree tests.
What changed
New file: tests/test_color_schemes.py (~46 tests)
Scope: Color dispatch, LaTeX color macro generation, legend TikZ output, and color_scheme passed into generate_tikz (including an .efg path).

What’s covered

get_player_color() — all schemes (default, gambit, distinctipy, colorblind): chance vs players, arbitrary player indices for dynamic schemes, and ValueError when gambit is used with more than six players (plus negative-player fallback where applicable).
color_definitions() — expected structure and content per scheme (e.g. default only defines chance, gambit defines the full fixed palette, distinctipy / colorblind emit p{n}rgb definitions with stable RNG behavior).
generate_legend() — empty list / default scheme returning no legend, non-default output containing expected TikZ (scope, rectangle for chance vs circle for players), and negative entries skipped.
Integration — generate_tikz(..., color_scheme=...) for each scheme on a small .ef fixture and an .efg game, asserting presence of expected color names in the emitted TikZ.

…generate_legend)

Covers all four schemes (default, gambit, distinctipy, colorblind),
edge cases like ValueError on gambit with >6 players, and end-to-end
integration with generate_tikz via the color_scheme parameter.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant