Add unit tests for color scheme logic (get_player_color, color_definitions, generate_legend)#61
Open
ravjot07 wants to merge 1 commit intogambitproject:mainfrom
Open
Add unit tests for color scheme logic (get_player_color, color_definitions, generate_legend)#61ravjot07 wants to merge 1 commit intogambitproject:mainfrom
ravjot07 wants to merge 1 commit intogambitproject:mainfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.