fix(sorts): add testmod() call to gnome_sort __main__ block - #15146
Open
Ankur-Kataria wants to merge 2 commits into
Open
fix(sorts): add testmod() call to gnome_sort __main__ block#15146Ankur-Kataria wants to merge 2 commits into
Ankur-Kataria wants to merge 2 commits into
Conversation
Fixes TheAlgorithms#14881 - gnome_sort.py did not call testmod() in its __main__ block, unlike other sort implementations (insertion_sort, shell_sort, etc.). Running the file directly with python3 gnome_sort.py would skip doctest verification. Now consistent with the rest of the sorts/ directory.
cclauss
reviewed
Sep 1, 2026
|
|
||
| testmod() | ||
|
|
||
| user_input = input("Enter numbers separated by a comma:\n").strip() |
Member
There was a problem hiding this comment.
This will crash in doctests as discussed in CONTRIBUTING.md
| @@ -0,0 +1 @@ | |||
| TheAlgorithms/Python | |||
Member
There was a problem hiding this comment.
This file is not needed or welcome.
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.
Describe your change:
sorts/gnome_sort.pywas not callingtestmod()in its__main__block, so running the file directly withpython3 gnome_sort.pysilently skipped doctest verification. Every other sort in this directory that has doctests (e.g.insertion_sort.py,shell_sort.py,comb_sort.py) already callstestmod()before prompting for user input.This PR adds the two-line pattern used across the rest of the directory:
Fixes #14881
Checklist: