Skip to content

Conversation

@seisman
Copy link
Member

@seisman seisman commented Jan 27, 2026

For complicated options like colorbar's -D, we encapsulate the parsing logic in private helper functions such as _alias_option_D. These helpers let us test argument strings directly for any combination of parameters, rather than testing each combination through Figure.colorbar calls, which would mean a growing collection of tests and baseline images.

Previously, we added dedicated tests like test_colorbar_alias_D in pygmt/tests/test_colorbar.py. This PR moves those tests inline as doctests within _alias_option_D instead. The benefits are:

  1. Tests can be written without switching between source and test files.
  2. Test files no longer need to import private functions or the AliasSystem class.

@seisman seisman added this to the 0.19.0 milestone Jan 27, 2026
@seisman seisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog needs review This PR has higher priority and needs review. labels Jan 27, 2026
@seisman seisman requested a review from Copilot January 27, 2026 07:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors test organization by moving tests for the _alias_option_D helper function from a dedicated test file into inline doctests within the function's docstring. This improves code maintainability by co-locating tests with the implementation.

Changes:

  • Removed the test_colorbar_alias_D test function from pygmt/tests/test_colorbar.py
  • Removed unnecessary imports (AliasSystem and _alias_option_D) from the test file
  • Added comprehensive doctests to _alias_option_D function in pygmt/src/colorbar.py covering all previous test cases

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pygmt/tests/test_colorbar.py Removed dedicated test function and its associated imports that are no longer needed
pygmt/src/colorbar.py Added doctests to _alias_option_D function documenting all parameter combinations previously tested

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Jan 27, 2026
@seisman seisman merged commit 3062417 into main Jan 28, 2026
32 of 35 checks passed
@seisman seisman deleted the colorbar/doctests branch January 28, 2026 02:15
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants