Skip to content

Add pytest for heap_sort - #13231

Merged
cclauss merged 4 commits into
TheAlgorithms:masterfrom
NavanithaSri:add-insertion-sort
Sep 4, 2026
Merged

Add pytest for heap_sort#13231
cclauss merged 4 commits into
TheAlgorithms:masterfrom
NavanithaSri:add-insertion-sort

Conversation

@NavanithaSri

Copy link
Copy Markdown
Contributor
  • I have read the contribution guidelines
  • My code follows PEP8 style
  • Added pytest or doctest
  • My code is tested
  • Other points not relevant left unchecked

@algorithms-keeperalgorithms-keeperBot added the awaiting reviews This PR is ready to be reviewed label Oct 5, 2025
@algorithms-keeperalgorithms-keeperBot added the tests are failing Do not merge until tests pass label Oct 5, 2025
@cclauss
cclauss enabled auto-merge (squash) September 4, 2026 17:41
@cclauss

Copy link
Copy Markdown
Member

@priya-sundaram-dev I merged this one because it would be good to start following the Python convention of having a tests/ directory. We can use if for pytests that cover similar algorithms like a parameterized tests. For all algorithms in the sorts directory, sort([10, -10, -1, 1, 0]), sort([1.1, -1.1, -1, 1, 0]), sort("Python!").

@algorithms-keeperalgorithms-keeperBot removed the awaiting reviews This PR is ready to be reviewed label Sep 4, 2026
@cclauss
cclauss merged commit 818ecfa into TheAlgorithms:masterSep 4, 2026
5 checks passed
@priya-sundaram-dev

Copy link
Copy Markdown
Contributor

Love it — a tests/ directory with parameterized tests is the right call. I ran with your three examples in #15185: a single test_sort_matches_builtin runs 20 general-purpose sorts × 9 inputs (your negatives / floats / "Python!" string, plus empty, single, duplicate-heavy, sorted, and reverse-sorted), all green, with the original test_heap_sort kept intact.

Two real bugs fell out while I was at it (kept out of the green suite so CI stays honest — can fix in separate PRs on your word):

  • tim_sort([])IndexError
  • tree_sort([3,3,1,2,2,1])[1,2,3] (drops duplicates)

The module docstring documents why the domain-restricted sorts (counting_sort, radix_sort, bead_sort, dutch_national_flag_sort, bitonic_sort, topological_sort, …) are excluded rather than silently skipped.

🤖 #ABotWroteThis

cclauss pushed a commit that referenced this pull request Sep 5, 2026
…batch) (#15189)
@cclauss managed the new-root-directory batch from #15081, closing/merging
all except #11842 (data-loss bug) and #12392 (no tests). Check the boxes for
the 10 now-resolved PRs across all three listings (flat, grouped-by-directory,
and 'Creates a new root directory').
Merged: #9896, #9388, #12141, #13231Closed: #13172, #12140, #13119, #11574, #13924, #14611
Still open (unchanged): #11842, #12392, #12648
Sign up for freeto 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.

3 participants

@NavanithaSri@cclauss@priya-sundaram-dev