11import unittest
22import random
33
4- from pygorithm .sorting import (bubble_sort ,
5- insertion_sort ,
6- selection_sort ,
7- merge_sort ,
8- quick_sort ,
9- counting_sort ,
10- bucket_sort ,
11- shell_sort ,
12- heap_sort )
13-
14- class SortingAlgorithmTests (unittest .TestCase ):
4+ from pygorithm .sorting import (
5+ bubble_sort ,
6+ insertion_sort ,
7+ selection_sort ,
8+ merge_sort ,
9+ quick_sort ,
10+ counting_sort ,
11+ bucket_sort ,
12+ shell_sort ,
13+ heap_sort )
14+
15+
16+ class TestSortingAlgorithm (unittest .TestCase ):
1517 def setUp (self ):
1618 # to test numeric numbers
1719 self .array = list (range (15 ))
@@ -24,69 +26,78 @@ def setUp(self):
2426 random .shuffle (self .alphaArray )
2527 self .sorted_alpha_array = sorted (string )
2628
27- class BubbleSortTest (SortingAlgorithmTests ):
29+
30+ class TestBubbleSortTest (TestSortingAlgorithm ):
2831 def test_bubble_sort (self ):
2932 self .result = bubble_sort .sort (self .array )
3033 self .assertEqual (self .result , self .sorted_array )
3134
3235 self .alphaResult = bubble_sort .sort (self .alphaArray )
3336 self .assertEqual (self .alphaResult , self .sorted_alpha_array )
3437
35- class InsertionSortTest (SortingAlgorithmTests ):
38+
39+ class TestInsertionSortTest (TestSortingAlgorithm ):
3640 def test_insertion_sort (self ):
3741 self .result = insertion_sort .sort (self .array )
3842 self .assertEqual (self .result , self .sorted_array )
3943
4044 self .alphaResult = insertion_sort .sort (self .alphaArray )
4145 self .assertEqual (self .alphaResult , self .sorted_alpha_array )
4246
43- class SelectionSortTest (SortingAlgorithmTests ):
47+
48+ class TestSelectionSortTest (TestSortingAlgorithm ):
4449 def test_selection_sort (self ):
4550 self .result = selection_sort .sort (self .array )
4651 self .assertEqual (self .result , self .sorted_array )
4752
4853 self .alphaResult = selection_sort .sort (self .alphaArray )
4954 self .assertEqual (self .alphaResult , self .sorted_alpha_array )
5055
51- class MergeSortTest (SortingAlgorithmTests ):
56+
57+ class TestMergeSortTest (TestSortingAlgorithm ):
5258 def test_merge_sort (self ):
5359 self .result = merge_sort .sort (self .array )
5460 self .assertEqual (self .result , self .sorted_array )
5561
5662 self .alphaResult = merge_sort .sort (self .alphaArray )
5763 self .assertEqual (self .alphaResult , self .sorted_alpha_array )
5864
59- class QuickSortTest (SortingAlgorithmTests ):
65+
66+ class TestQuickSortTest (TestSortingAlgorithm ):
6067 def test_quick_sort (self ):
6168 self .result = quick_sort .sort (self .array )
6269 self .assertEqual (self .result , self .sorted_array )
6370
6471 self .alphaResult = quick_sort .sort (self .alphaArray )
6572 self .assertEqual (self .alphaResult , self .sorted_alpha_array )
6673
67- class CountingSortTest (SortingAlgorithmTests ):
74+
75+ class TestCountingSortTest (TestSortingAlgorithm ):
6876 def test_counting_sort (self ):
6977 # counting sort is an integer based sort
7078 self .result = counting_sort .sort (self .array )
7179 self .assertEqual (self .result , self .sorted_array )
7280
73- class BucketSortTest (SortingAlgorithmTests ):
81+
82+ class TestBucketSortTest (TestSortingAlgorithm ):
7483 def test_bucket_sort (self ):
7584 self .result = bucket_sort .sort (self .array )
7685 self .assertEqual (self .result , self .sorted_array )
7786
7887 self .alphaResult = bucket_sort .sort (self .alphaArray )
7988 self .assertEqual (self .alphaResult , self .sorted_alpha_array )
8089
81- class ShellSortTest (SortingAlgorithmTests ):
90+
91+ class TestShellSortTest (TestSortingAlgorithm ):
8292 def test_shell_sort (self ):
8393 self .result = shell_sort .sort (self .array )
8494 self .assertEqual (self .result , self .sorted_array )
8595
8696 self .alphaResult = shell_sort .sort (self .alphaArray )
8797 self .assertEqual (self .alphaResult , self .sorted_alpha_array )
8898
89- class HeapSortTest (SortingAlgorithmTests ):
99+
100+ class TestHeapSortTest (TestSortingAlgorithm ):
90101 def test_heap_sort (self ):
91102 self .result = heap_sort .sort (self .array )
92103 self .assertEqual (self .result , self .sorted_array )
0 commit comments