From e81d624c0a277be4cd36ee3e062330e6de185b41 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Thu, 25 Dec 2025 15:19:16 +0300 Subject: [PATCH 01/33] Add heapsort.py --- src/hw_pytest/heapsort.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/hw_pytest/heapsort.py diff --git a/src/hw_pytest/heapsort.py b/src/hw_pytest/heapsort.py new file mode 100644 index 0000000..d3557a5 --- /dev/null +++ b/src/hw_pytest/heapsort.py @@ -0,0 +1,32 @@ +def heap_sort(arr): + if len(arr) <= 1: + return arr + + n = len(arr) + for i in range(n // 2 - 1, -1, -1): + heapify(arr, n, i) + + for i in range(n - 1, 0, -1): + arr[0], arr[i] = arr[i], arr[0] + heapify(arr, i, 0) + + return arr + + +def heapify(arr, n, i): + while True: + largest = i + left = 2 * i + 1 + right = 2 * i + 2 + + if left < n and arr[left] > arr[largest]: + largest = left + + if right < n and arr[right] > arr[largest]: + largest = right + + if largest == i: + break + + arr[i], arr[largest] = arr[largest], arr[i] + i = largest From f48c20b2423968460fa739439370c99a67bf4c32 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Thu, 25 Dec 2025 15:19:38 +0300 Subject: [PATCH 02/33] Create other_sorts.py --- src/hw_pytest/other_sorts.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/hw_pytest/other_sorts.py diff --git a/src/hw_pytest/other_sorts.py b/src/hw_pytest/other_sorts.py new file mode 100644 index 0000000..f35a53a --- /dev/null +++ b/src/hw_pytest/other_sorts.py @@ -0,0 +1,19 @@ +def bubble_sort(arr): + n = len(arr) + for i in range(n - 1): + for j in range(n - i - 1): + if arr[j] > arr[j + 1]: + arr[j], arr[j + 1] = arr[j + 1], arr[j] + return arr + + +def insertion_sort(arr): + for i in range(1, len(arr)): + key = arr[i] + j = i - 1 + while j >= 0 and arr[j] > key: + arr[j + 1] = arr[j] + j -= 1 + arr[j + 1] = key + return arr + From 98cf1408f82c0618691d14ad3c745c4c59cbae00 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Thu, 25 Dec 2025 15:20:31 +0300 Subject: [PATCH 03/33] Add heapsort_tests.py --- src/hw_pytest/heapsort_tests.py | 137 ++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/hw_pytest/heapsort_tests.py diff --git a/src/hw_pytest/heapsort_tests.py b/src/hw_pytest/heapsort_tests.py new file mode 100644 index 0000000..20b50e7 --- /dev/null +++ b/src/hw_pytest/heapsort_tests.py @@ -0,0 +1,137 @@ +import pytest +from heapsort import heap_sort +from other_sorts import bubble_sort, insertion_sort + +# обычные unit тесты и крайние случаи +@pytest.mark.empty +def test_heap_sort_empty(): + """Тест для пустого списка""" + result = heap_sort([]) + assert result == [] + + +@pytest.mark.single +def test_heap_sort_single(): + """Тест для списка из одного элемента""" + result = heap_sort([42]) + assert result == [42] + + +@pytest.mark.sorted +def test_heap_sort_sorted(): + """Тест для уже отсортированного списка""" + result = heap_sort([1, 2, 3, 4, 5]) + assert result == [1, 2, 3, 4, 5] + + +@pytest.mark.reversed +def test_heap_sort_reversed(): + """Тест для списка, отсортированного в обратном порядке""" + result = heap_sort([5, 4, 3, 2, 1]) + assert result == [1, 2, 3, 4, 5] + + +@pytest.mark.duplicates +def test_heap_sort_with_duplicates(): + """Тест для списка с дубликатами""" + result = heap_sort([1, 3, 1, 3, 2, 1, 1, 1, 2]) + assert result == [1, 1, 1, 1, 1, 2, 2, 3, 3] + +@pytest.mark.negative +def test_heap_sort_negative_num(): + """Тест с отрицательными числами""" + result = heap_sort([-5, -1, -3, -2, -181818, -4]) + assert result == [-181818, -5, -4, -3, -2, -1] + + +@pytest.mark.mixed +def test_heap_sort_mixed(): + """Тест с положительными и отрицательными числами""" + result = heap_sort([250000, -3, 5, -1, 2, -1000, 0, -2]) + assert result == [-1000, -3, -2, -1, 0, 2, 5, 250000] + + +@pytest.mark.float +def test_heap_sort_floats(): + """Тест с числами с плавающей точкой""" + result = heap_sort([3.6, 1.2, 4.8, 2.1, 0.5, 2.0]) + assert result == [0.5, 1.2, 2.0, 2.1, 3.6, 4.8] + +# тесты для сравнения heapsort и insertion sort и bubble sort +@pytest.mark.all_sorts_empty +def test_all_sorts_empty(): + """Тест для пустого списка""" + heap_result = heap_sort([]) + insertion_result = insertion_sort([]) + bubble_result = bubble_sort([]) + python_result = sorted([]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_single +def test_all_sorts_single(): + """Тест для списка из одного элемента""" + heap_result = heap_sort([52]) + insertion_result = insertion_sort([52]) + bubble_result = bubble_sort([52]) + python_result = sorted([52]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_sorted +def test_all_sorts_sorted(): + """Тест для уже отсортированного списка""" + heap_result = heap_sort([1,2,3]) + insertion_result = insertion_sort([1,2,3]) + bubble_result = bubble_sort([1,2,3]) + python_result = sorted([1,2,3]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_reversed +def test_all_sorts_reversed(): + """Тест для списка, отсортированного в обратном порядке""" + heap_result = heap_sort([5, 4, 3]) + insertion_result = insertion_sort([5, 4, 3]) + bubble_result = bubble_sort([5, 4, 3]) + python_result = sorted([5, 4, 3]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_duplicates +def test_all_sorts_with_duplicates(): + """Тест для списка с дубликатами""" + heap_result = heap_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + insertion_result = insertion_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + bubble_result = bubble_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + python_result = sorted([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + assert heap_result == insertion_result == bubble_result == python_result + +@pytest.mark.all_sorts_negative +def test_all_sorts_negative_num(): + """Тест с отрицательными числами""" + heap_result = heap_sort([-762, -10, -387, -37072]) + insertion_result = insertion_sort([-762, -10, -387, -37072]) + bubble_result = bubble_sort([-762, -10, -387, -37072]) + python_result = sorted([-762, -10, -387, -37072]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_mixed +def test_all_sorts_mixed(): + """Тест с положительными и отрицательными числами""" + heap_result = heap_sort([100, -1, 0, -387, 153]) + insertion_result = insertion_sort([100, -1, 0, -387, 153]) + bubble_result = bubble_sort([100, -1, 0, -387, 153]) + python_result = sorted([100, -1, 0, -387, 153]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_float +def test_all_sorts_floats(): + """Тест с числами с плавающей точкой""" + heap_result = heap_sort([1.0, -1.9, 0.0, -3.8, 153.5]) + insertion_result = insertion_sort([1.0, -1.9, 0.0, -3.8, 153.5]) + bubble_result = bubble_sort([1.0, -1.9, 0.0, -3.8, 153.5]) + python_result = sorted([1.0, -1.9, 0.0, -3.8, 153.5]) + assert heap_result == insertion_result == bubble_result == python_result From 1f0be3a328a54e7e20426d1885245862d90a34e1 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Thu, 25 Dec 2025 15:22:58 +0300 Subject: [PATCH 04/33] Add heapsort-tests.yml --- .github/workflows/heapsort-tests.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/heapsort-tests.yml diff --git a/.github/workflows/heapsort-tests.yml b/.github/workflows/heapsort-tests.yml new file mode 100644 index 0000000..5501ba9 --- /dev/null +++ b/.github/workflows/heapsort-tests.yml @@ -0,0 +1,23 @@ +name: Run Tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install pytest + run: pip install pytest + + - name: Run tests + run: python -m pytest heapsort_tests.py -v + + From 238f4cc7b90d18ef1f31c2445c3ab179674acd68 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Thu, 25 Dec 2025 15:25:56 +0300 Subject: [PATCH 05/33] Fixed heapsort-tests.yml --- .github/workflows/heapsort-tests.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/heapsort-tests.yml b/.github/workflows/heapsort-tests.yml index 5501ba9..23362b5 100644 --- a/.github/workflows/heapsort-tests.yml +++ b/.github/workflows/heapsort-tests.yml @@ -1,23 +1,24 @@ -name: Run Tests +name: Run Heap Sort Tests on: [push, pull_request] jobs: test: runs-on: ubuntu-latest - + steps: - uses: actions/checkout@v3 - + - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.9' - + python-version: '3.13' + - name: Install pytest run: pip install pytest - + - name: Run tests - run: python -m pytest heapsort_tests.py -v - + run: | + cd src/hw_pytest/ + python -m pytest heapsort_tests.py -v From a5d5670bf2c1875fd9cbd11c2c2d22786c113c33 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:44:46 +0300 Subject: [PATCH 06/33] Create hw_heapsort --- src/hw_heapsort | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/hw_heapsort diff --git a/src/hw_heapsort b/src/hw_heapsort new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/hw_heapsort @@ -0,0 +1 @@ + From df5390b503b183d09956a77e1473648588bf41ef Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:45:01 +0300 Subject: [PATCH 07/33] Delete src/hw_heapsort --- src/hw_heapsort | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/hw_heapsort diff --git a/src/hw_heapsort b/src/hw_heapsort deleted file mode 100644 index 8b13789..0000000 --- a/src/hw_heapsort +++ /dev/null @@ -1 +0,0 @@ - From aa77001e1cd8ee78987948b3505d5b9c6c1f6b28 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:47:40 +0300 Subject: [PATCH 08/33] Add heapsort.py in new dir --- src/hw_heapsort/heapsort.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/hw_heapsort/heapsort.py diff --git a/src/hw_heapsort/heapsort.py b/src/hw_heapsort/heapsort.py new file mode 100644 index 0000000..d3557a5 --- /dev/null +++ b/src/hw_heapsort/heapsort.py @@ -0,0 +1,32 @@ +def heap_sort(arr): + if len(arr) <= 1: + return arr + + n = len(arr) + for i in range(n // 2 - 1, -1, -1): + heapify(arr, n, i) + + for i in range(n - 1, 0, -1): + arr[0], arr[i] = arr[i], arr[0] + heapify(arr, i, 0) + + return arr + + +def heapify(arr, n, i): + while True: + largest = i + left = 2 * i + 1 + right = 2 * i + 2 + + if left < n and arr[left] > arr[largest]: + largest = left + + if right < n and arr[right] > arr[largest]: + largest = right + + if largest == i: + break + + arr[i], arr[largest] = arr[largest], arr[i] + i = largest From a1920b62c352aa64fa7af9b24c079cb79574ea0d Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:48:07 +0300 Subject: [PATCH 09/33] Create other_sorts.py in new dir --- src/hw_heapsort/other_sorts.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/hw_heapsort/other_sorts.py diff --git a/src/hw_heapsort/other_sorts.py b/src/hw_heapsort/other_sorts.py new file mode 100644 index 0000000..c2d55a5 --- /dev/null +++ b/src/hw_heapsort/other_sorts.py @@ -0,0 +1,18 @@ +def bubble_sort(arr): + n = len(arr) + for i in range(n - 1): + for j in range(n - i - 1): + if arr[j] > arr[j + 1]: + arr[j], arr[j + 1] = arr[j + 1], arr[j] + return arr + + +def insertion_sort(arr): + for i in range(1, len(arr)): + key = arr[i] + j = i - 1 + while j >= 0 and arr[j] > key: + arr[j + 1] = arr[j] + j -= 1 + arr[j + 1] = key + return arr From 022c38a5fc5362185e238b620c8bed9f2bb593f9 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:49:11 +0300 Subject: [PATCH 10/33] Create tests_heapsort.py in dir only for tests --- src/hw_heapsort/tests/tests_heapsort.py | 137 ++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/hw_heapsort/tests/tests_heapsort.py diff --git a/src/hw_heapsort/tests/tests_heapsort.py b/src/hw_heapsort/tests/tests_heapsort.py new file mode 100644 index 0000000..20b50e7 --- /dev/null +++ b/src/hw_heapsort/tests/tests_heapsort.py @@ -0,0 +1,137 @@ +import pytest +from heapsort import heap_sort +from other_sorts import bubble_sort, insertion_sort + +# обычные unit тесты и крайние случаи +@pytest.mark.empty +def test_heap_sort_empty(): + """Тест для пустого списка""" + result = heap_sort([]) + assert result == [] + + +@pytest.mark.single +def test_heap_sort_single(): + """Тест для списка из одного элемента""" + result = heap_sort([42]) + assert result == [42] + + +@pytest.mark.sorted +def test_heap_sort_sorted(): + """Тест для уже отсортированного списка""" + result = heap_sort([1, 2, 3, 4, 5]) + assert result == [1, 2, 3, 4, 5] + + +@pytest.mark.reversed +def test_heap_sort_reversed(): + """Тест для списка, отсортированного в обратном порядке""" + result = heap_sort([5, 4, 3, 2, 1]) + assert result == [1, 2, 3, 4, 5] + + +@pytest.mark.duplicates +def test_heap_sort_with_duplicates(): + """Тест для списка с дубликатами""" + result = heap_sort([1, 3, 1, 3, 2, 1, 1, 1, 2]) + assert result == [1, 1, 1, 1, 1, 2, 2, 3, 3] + +@pytest.mark.negative +def test_heap_sort_negative_num(): + """Тест с отрицательными числами""" + result = heap_sort([-5, -1, -3, -2, -181818, -4]) + assert result == [-181818, -5, -4, -3, -2, -1] + + +@pytest.mark.mixed +def test_heap_sort_mixed(): + """Тест с положительными и отрицательными числами""" + result = heap_sort([250000, -3, 5, -1, 2, -1000, 0, -2]) + assert result == [-1000, -3, -2, -1, 0, 2, 5, 250000] + + +@pytest.mark.float +def test_heap_sort_floats(): + """Тест с числами с плавающей точкой""" + result = heap_sort([3.6, 1.2, 4.8, 2.1, 0.5, 2.0]) + assert result == [0.5, 1.2, 2.0, 2.1, 3.6, 4.8] + +# тесты для сравнения heapsort и insertion sort и bubble sort +@pytest.mark.all_sorts_empty +def test_all_sorts_empty(): + """Тест для пустого списка""" + heap_result = heap_sort([]) + insertion_result = insertion_sort([]) + bubble_result = bubble_sort([]) + python_result = sorted([]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_single +def test_all_sorts_single(): + """Тест для списка из одного элемента""" + heap_result = heap_sort([52]) + insertion_result = insertion_sort([52]) + bubble_result = bubble_sort([52]) + python_result = sorted([52]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_sorted +def test_all_sorts_sorted(): + """Тест для уже отсортированного списка""" + heap_result = heap_sort([1,2,3]) + insertion_result = insertion_sort([1,2,3]) + bubble_result = bubble_sort([1,2,3]) + python_result = sorted([1,2,3]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_reversed +def test_all_sorts_reversed(): + """Тест для списка, отсортированного в обратном порядке""" + heap_result = heap_sort([5, 4, 3]) + insertion_result = insertion_sort([5, 4, 3]) + bubble_result = bubble_sort([5, 4, 3]) + python_result = sorted([5, 4, 3]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_duplicates +def test_all_sorts_with_duplicates(): + """Тест для списка с дубликатами""" + heap_result = heap_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + insertion_result = insertion_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + bubble_result = bubble_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + python_result = sorted([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + assert heap_result == insertion_result == bubble_result == python_result + +@pytest.mark.all_sorts_negative +def test_all_sorts_negative_num(): + """Тест с отрицательными числами""" + heap_result = heap_sort([-762, -10, -387, -37072]) + insertion_result = insertion_sort([-762, -10, -387, -37072]) + bubble_result = bubble_sort([-762, -10, -387, -37072]) + python_result = sorted([-762, -10, -387, -37072]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_mixed +def test_all_sorts_mixed(): + """Тест с положительными и отрицательными числами""" + heap_result = heap_sort([100, -1, 0, -387, 153]) + insertion_result = insertion_sort([100, -1, 0, -387, 153]) + bubble_result = bubble_sort([100, -1, 0, -387, 153]) + python_result = sorted([100, -1, 0, -387, 153]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_float +def test_all_sorts_floats(): + """Тест с числами с плавающей точкой""" + heap_result = heap_sort([1.0, -1.9, 0.0, -3.8, 153.5]) + insertion_result = insertion_sort([1.0, -1.9, 0.0, -3.8, 153.5]) + bubble_result = bubble_sort([1.0, -1.9, 0.0, -3.8, 153.5]) + python_result = sorted([1.0, -1.9, 0.0, -3.8, 153.5]) + assert heap_result == insertion_result == bubble_result == python_result From af6339c3cb1d183daeaffe748eccd043a62643d3 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:50:14 +0300 Subject: [PATCH 11/33] Delete src/hw_pytest directory --- src/hw_pytest/heapsort.py | 32 -------- src/hw_pytest/heapsort_tests.py | 137 -------------------------------- src/hw_pytest/other_sorts.py | 19 ----- 3 files changed, 188 deletions(-) delete mode 100644 src/hw_pytest/heapsort.py delete mode 100644 src/hw_pytest/heapsort_tests.py delete mode 100644 src/hw_pytest/other_sorts.py diff --git a/src/hw_pytest/heapsort.py b/src/hw_pytest/heapsort.py deleted file mode 100644 index d3557a5..0000000 --- a/src/hw_pytest/heapsort.py +++ /dev/null @@ -1,32 +0,0 @@ -def heap_sort(arr): - if len(arr) <= 1: - return arr - - n = len(arr) - for i in range(n // 2 - 1, -1, -1): - heapify(arr, n, i) - - for i in range(n - 1, 0, -1): - arr[0], arr[i] = arr[i], arr[0] - heapify(arr, i, 0) - - return arr - - -def heapify(arr, n, i): - while True: - largest = i - left = 2 * i + 1 - right = 2 * i + 2 - - if left < n and arr[left] > arr[largest]: - largest = left - - if right < n and arr[right] > arr[largest]: - largest = right - - if largest == i: - break - - arr[i], arr[largest] = arr[largest], arr[i] - i = largest diff --git a/src/hw_pytest/heapsort_tests.py b/src/hw_pytest/heapsort_tests.py deleted file mode 100644 index 20b50e7..0000000 --- a/src/hw_pytest/heapsort_tests.py +++ /dev/null @@ -1,137 +0,0 @@ -import pytest -from heapsort import heap_sort -from other_sorts import bubble_sort, insertion_sort - -# обычные unit тесты и крайние случаи -@pytest.mark.empty -def test_heap_sort_empty(): - """Тест для пустого списка""" - result = heap_sort([]) - assert result == [] - - -@pytest.mark.single -def test_heap_sort_single(): - """Тест для списка из одного элемента""" - result = heap_sort([42]) - assert result == [42] - - -@pytest.mark.sorted -def test_heap_sort_sorted(): - """Тест для уже отсортированного списка""" - result = heap_sort([1, 2, 3, 4, 5]) - assert result == [1, 2, 3, 4, 5] - - -@pytest.mark.reversed -def test_heap_sort_reversed(): - """Тест для списка, отсортированного в обратном порядке""" - result = heap_sort([5, 4, 3, 2, 1]) - assert result == [1, 2, 3, 4, 5] - - -@pytest.mark.duplicates -def test_heap_sort_with_duplicates(): - """Тест для списка с дубликатами""" - result = heap_sort([1, 3, 1, 3, 2, 1, 1, 1, 2]) - assert result == [1, 1, 1, 1, 1, 2, 2, 3, 3] - -@pytest.mark.negative -def test_heap_sort_negative_num(): - """Тест с отрицательными числами""" - result = heap_sort([-5, -1, -3, -2, -181818, -4]) - assert result == [-181818, -5, -4, -3, -2, -1] - - -@pytest.mark.mixed -def test_heap_sort_mixed(): - """Тест с положительными и отрицательными числами""" - result = heap_sort([250000, -3, 5, -1, 2, -1000, 0, -2]) - assert result == [-1000, -3, -2, -1, 0, 2, 5, 250000] - - -@pytest.mark.float -def test_heap_sort_floats(): - """Тест с числами с плавающей точкой""" - result = heap_sort([3.6, 1.2, 4.8, 2.1, 0.5, 2.0]) - assert result == [0.5, 1.2, 2.0, 2.1, 3.6, 4.8] - -# тесты для сравнения heapsort и insertion sort и bubble sort -@pytest.mark.all_sorts_empty -def test_all_sorts_empty(): - """Тест для пустого списка""" - heap_result = heap_sort([]) - insertion_result = insertion_sort([]) - bubble_result = bubble_sort([]) - python_result = sorted([]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_single -def test_all_sorts_single(): - """Тест для списка из одного элемента""" - heap_result = heap_sort([52]) - insertion_result = insertion_sort([52]) - bubble_result = bubble_sort([52]) - python_result = sorted([52]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_sorted -def test_all_sorts_sorted(): - """Тест для уже отсортированного списка""" - heap_result = heap_sort([1,2,3]) - insertion_result = insertion_sort([1,2,3]) - bubble_result = bubble_sort([1,2,3]) - python_result = sorted([1,2,3]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_reversed -def test_all_sorts_reversed(): - """Тест для списка, отсортированного в обратном порядке""" - heap_result = heap_sort([5, 4, 3]) - insertion_result = insertion_sort([5, 4, 3]) - bubble_result = bubble_sort([5, 4, 3]) - python_result = sorted([5, 4, 3]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_duplicates -def test_all_sorts_with_duplicates(): - """Тест для списка с дубликатами""" - heap_result = heap_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) - insertion_result = insertion_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) - bubble_result = bubble_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) - python_result = sorted([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) - assert heap_result == insertion_result == bubble_result == python_result - -@pytest.mark.all_sorts_negative -def test_all_sorts_negative_num(): - """Тест с отрицательными числами""" - heap_result = heap_sort([-762, -10, -387, -37072]) - insertion_result = insertion_sort([-762, -10, -387, -37072]) - bubble_result = bubble_sort([-762, -10, -387, -37072]) - python_result = sorted([-762, -10, -387, -37072]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_mixed -def test_all_sorts_mixed(): - """Тест с положительными и отрицательными числами""" - heap_result = heap_sort([100, -1, 0, -387, 153]) - insertion_result = insertion_sort([100, -1, 0, -387, 153]) - bubble_result = bubble_sort([100, -1, 0, -387, 153]) - python_result = sorted([100, -1, 0, -387, 153]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_float -def test_all_sorts_floats(): - """Тест с числами с плавающей точкой""" - heap_result = heap_sort([1.0, -1.9, 0.0, -3.8, 153.5]) - insertion_result = insertion_sort([1.0, -1.9, 0.0, -3.8, 153.5]) - bubble_result = bubble_sort([1.0, -1.9, 0.0, -3.8, 153.5]) - python_result = sorted([1.0, -1.9, 0.0, -3.8, 153.5]) - assert heap_result == insertion_result == bubble_result == python_result diff --git a/src/hw_pytest/other_sorts.py b/src/hw_pytest/other_sorts.py deleted file mode 100644 index f35a53a..0000000 --- a/src/hw_pytest/other_sorts.py +++ /dev/null @@ -1,19 +0,0 @@ -def bubble_sort(arr): - n = len(arr) - for i in range(n - 1): - for j in range(n - i - 1): - if arr[j] > arr[j + 1]: - arr[j], arr[j + 1] = arr[j + 1], arr[j] - return arr - - -def insertion_sort(arr): - for i in range(1, len(arr)): - key = arr[i] - j = i - 1 - while j >= 0 and arr[j] > key: - arr[j + 1] = arr[j] - j -= 1 - arr[j + 1] = key - return arr - From f84f34be94af576929bb88009c92cb62a947cc92 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:51:11 +0300 Subject: [PATCH 12/33] Add __init__.py --- src/hw_heapsort/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/hw_heapsort/__init__.py diff --git a/src/hw_heapsort/__init__.py b/src/hw_heapsort/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/hw_heapsort/__init__.py @@ -0,0 +1 @@ + From 343bce3f82e9449c3d03257528538024ebb0e58a Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:51:48 +0300 Subject: [PATCH 13/33] Update heapsort-tests.yml --- .github/workflows/heapsort-tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/heapsort-tests.yml b/.github/workflows/heapsort-tests.yml index 23362b5..2348612 100644 --- a/.github/workflows/heapsort-tests.yml +++ b/.github/workflows/heapsort-tests.yml @@ -19,6 +19,5 @@ jobs: - name: Run tests run: | - cd src/hw_pytest/ - python -m pytest heapsort_tests.py -v + python -m pytest tests_heapsort.py -v From 0e6c02b5723cb9e003bc7189dd7c68dff4804e39 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:54:04 +0300 Subject: [PATCH 14/33] Create __init__.py --- src/hw_heapsort/tests/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/hw_heapsort/tests/__init__.py diff --git a/src/hw_heapsort/tests/__init__.py b/src/hw_heapsort/tests/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/hw_heapsort/tests/__init__.py @@ -0,0 +1 @@ + From 8585c9febcc8294930ca4a16d40ab8d5aba4c77a Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:55:09 +0300 Subject: [PATCH 15/33] Moved all sorts to sorts.py and rename heapsort.py to sorts.py --- src/hw_heapsort/{heapsort.py => sorts.py} | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) rename src/hw_heapsort/{heapsort.py => sorts.py} (59%) diff --git a/src/hw_heapsort/heapsort.py b/src/hw_heapsort/sorts.py similarity index 59% rename from src/hw_heapsort/heapsort.py rename to src/hw_heapsort/sorts.py index d3557a5..f79e98a 100644 --- a/src/hw_heapsort/heapsort.py +++ b/src/hw_heapsort/sorts.py @@ -30,3 +30,23 @@ def heapify(arr, n, i): arr[i], arr[largest] = arr[largest], arr[i] i = largest + + +def bubble_sort(arr): + n = len(arr) + for i in range(n - 1): + for j in range(n - i - 1): + if arr[j] > arr[j + 1]: + arr[j], arr[j + 1] = arr[j + 1], arr[j] + return arr + + +def insertion_sort(arr): + for i in range(1, len(arr)): + key = arr[i] + j = i - 1 + while j >= 0 and arr[j] > key: + arr[j + 1] = arr[j] + j -= 1 + arr[j + 1] = key + return arr From e40cc7622c0bba5e8654d8d4c89f6aaff855885a Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:55:31 +0300 Subject: [PATCH 16/33] Delete src/hw_heapsort/other_sorts.py --- src/hw_heapsort/other_sorts.py | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 src/hw_heapsort/other_sorts.py diff --git a/src/hw_heapsort/other_sorts.py b/src/hw_heapsort/other_sorts.py deleted file mode 100644 index c2d55a5..0000000 --- a/src/hw_heapsort/other_sorts.py +++ /dev/null @@ -1,18 +0,0 @@ -def bubble_sort(arr): - n = len(arr) - for i in range(n - 1): - for j in range(n - i - 1): - if arr[j] > arr[j + 1]: - arr[j], arr[j + 1] = arr[j + 1], arr[j] - return arr - - -def insertion_sort(arr): - for i in range(1, len(arr)): - key = arr[i] - j = i - 1 - while j >= 0 and arr[j] > key: - arr[j + 1] = arr[j] - j -= 1 - arr[j + 1] = key - return arr From e15fc7aa35a14140d7377cd9e1566305b69bc025 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:56:13 +0300 Subject: [PATCH 17/33] Update path in tests_heapsort.py --- src/hw_heapsort/tests/tests_heapsort.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hw_heapsort/tests/tests_heapsort.py b/src/hw_heapsort/tests/tests_heapsort.py index 20b50e7..31b9f8b 100644 --- a/src/hw_heapsort/tests/tests_heapsort.py +++ b/src/hw_heapsort/tests/tests_heapsort.py @@ -1,6 +1,5 @@ import pytest -from heapsort import heap_sort -from other_sorts import bubble_sort, insertion_sort +from ../sorts.py import heap_sort, bubble_sort, insertion_sort # обычные unit тесты и крайние случаи @pytest.mark.empty From e7db446122a366d24001c991fc164d8808b64157 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:56:24 +0300 Subject: [PATCH 18/33] Delete src/hw_heapsort/__init__.py --- src/hw_heapsort/__init__.py | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/hw_heapsort/__init__.py diff --git a/src/hw_heapsort/__init__.py b/src/hw_heapsort/__init__.py deleted file mode 100644 index 8b13789..0000000 --- a/src/hw_heapsort/__init__.py +++ /dev/null @@ -1 +0,0 @@ - From ec7a6041615c55426cf762a8911d6194eb8dab59 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 12:57:36 +0300 Subject: [PATCH 19/33] Update path in heapsort-tests.yml --- .github/workflows/heapsort-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/heapsort-tests.yml b/.github/workflows/heapsort-tests.yml index 2348612..92869ea 100644 --- a/.github/workflows/heapsort-tests.yml +++ b/.github/workflows/heapsort-tests.yml @@ -19,5 +19,6 @@ jobs: - name: Run tests run: | + cd ../src/hw_heapsort/tests python -m pytest tests_heapsort.py -v From f436bb5b171c9b971253aeacefe0164154c006dd Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:00:53 +0300 Subject: [PATCH 20/33] Update path in heapsort-tests.yml --- .github/workflows/heapsort-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/heapsort-tests.yml b/.github/workflows/heapsort-tests.yml index 92869ea..b5e25d6 100644 --- a/.github/workflows/heapsort-tests.yml +++ b/.github/workflows/heapsort-tests.yml @@ -19,6 +19,7 @@ jobs: - name: Run tests run: | - cd ../src/hw_heapsort/tests + cd .. + cd /src/hw_heapsort/tests python -m pytest tests_heapsort.py -v From de8eda444d5a79480d3b3320537d86acafde6d64 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:03:19 +0300 Subject: [PATCH 21/33] Update path in heapsort-tests.yml --- .github/workflows/heapsort-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/heapsort-tests.yml b/.github/workflows/heapsort-tests.yml index b5e25d6..1f99d34 100644 --- a/.github/workflows/heapsort-tests.yml +++ b/.github/workflows/heapsort-tests.yml @@ -20,6 +20,6 @@ jobs: - name: Run tests run: | cd .. - cd /src/hw_heapsort/tests + cd src/hw_heapsort/tests python -m pytest tests_heapsort.py -v From ed1e3c91ce00c4a2e0b4777b2746a1a08d2de3dc Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:10:04 +0300 Subject: [PATCH 22/33] Add tests_heapsort.py out of src --- tests/tests_heapsort.py | 136 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 tests/tests_heapsort.py diff --git a/tests/tests_heapsort.py b/tests/tests_heapsort.py new file mode 100644 index 0000000..eba6405 --- /dev/null +++ b/tests/tests_heapsort.py @@ -0,0 +1,136 @@ +import pytest +from src/hw_heapsort/sorts.py import heap_sort, bubble_sort, insertion_sort + +# обычные unit тесты и крайние случаи +@pytest.mark.empty +def test_heap_sort_empty(): + """Тест для пустого списка""" + result = heap_sort([]) + assert result == [] + + +@pytest.mark.single +def test_heap_sort_single(): + """Тест для списка из одного элемента""" + result = heap_sort([42]) + assert result == [42] + + +@pytest.mark.sorted +def test_heap_sort_sorted(): + """Тест для уже отсортированного списка""" + result = heap_sort([1, 2, 3, 4, 5]) + assert result == [1, 2, 3, 4, 5] + + +@pytest.mark.reversed +def test_heap_sort_reversed(): + """Тест для списка, отсортированного в обратном порядке""" + result = heap_sort([5, 4, 3, 2, 1]) + assert result == [1, 2, 3, 4, 5] + + +@pytest.mark.duplicates +def test_heap_sort_with_duplicates(): + """Тест для списка с дубликатами""" + result = heap_sort([1, 3, 1, 3, 2, 1, 1, 1, 2]) + assert result == [1, 1, 1, 1, 1, 2, 2, 3, 3] + +@pytest.mark.negative +def test_heap_sort_negative_num(): + """Тест с отрицательными числами""" + result = heap_sort([-5, -1, -3, -2, -181818, -4]) + assert result == [-181818, -5, -4, -3, -2, -1] + + +@pytest.mark.mixed +def test_heap_sort_mixed(): + """Тест с положительными и отрицательными числами""" + result = heap_sort([250000, -3, 5, -1, 2, -1000, 0, -2]) + assert result == [-1000, -3, -2, -1, 0, 2, 5, 250000] + + +@pytest.mark.float +def test_heap_sort_floats(): + """Тест с числами с плавающей точкой""" + result = heap_sort([3.6, 1.2, 4.8, 2.1, 0.5, 2.0]) + assert result == [0.5, 1.2, 2.0, 2.1, 3.6, 4.8] + +# тесты для сравнения heapsort и insertion sort и bubble sort +@pytest.mark.all_sorts_empty +def test_all_sorts_empty(): + """Тест для пустого списка""" + heap_result = heap_sort([]) + insertion_result = insertion_sort([]) + bubble_result = bubble_sort([]) + python_result = sorted([]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_single +def test_all_sorts_single(): + """Тест для списка из одного элемента""" + heap_result = heap_sort([52]) + insertion_result = insertion_sort([52]) + bubble_result = bubble_sort([52]) + python_result = sorted([52]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_sorted +def test_all_sorts_sorted(): + """Тест для уже отсортированного списка""" + heap_result = heap_sort([1,2,3]) + insertion_result = insertion_sort([1,2,3]) + bubble_result = bubble_sort([1,2,3]) + python_result = sorted([1,2,3]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_reversed +def test_all_sorts_reversed(): + """Тест для списка, отсортированного в обратном порядке""" + heap_result = heap_sort([5, 4, 3]) + insertion_result = insertion_sort([5, 4, 3]) + bubble_result = bubble_sort([5, 4, 3]) + python_result = sorted([5, 4, 3]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_duplicates +def test_all_sorts_with_duplicates(): + """Тест для списка с дубликатами""" + heap_result = heap_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + insertion_result = insertion_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + bubble_result = bubble_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + python_result = sorted([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) + assert heap_result == insertion_result == bubble_result == python_result + +@pytest.mark.all_sorts_negative +def test_all_sorts_negative_num(): + """Тест с отрицательными числами""" + heap_result = heap_sort([-762, -10, -387, -37072]) + insertion_result = insertion_sort([-762, -10, -387, -37072]) + bubble_result = bubble_sort([-762, -10, -387, -37072]) + python_result = sorted([-762, -10, -387, -37072]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_mixed +def test_all_sorts_mixed(): + """Тест с положительными и отрицательными числами""" + heap_result = heap_sort([100, -1, 0, -387, 153]) + insertion_result = insertion_sort([100, -1, 0, -387, 153]) + bubble_result = bubble_sort([100, -1, 0, -387, 153]) + python_result = sorted([100, -1, 0, -387, 153]) + assert heap_result == insertion_result == bubble_result == python_result + + +@pytest.mark.all_sorts_float +def test_all_sorts_floats(): + """Тест с числами с плавающей точкой""" + heap_result = heap_sort([1.0, -1.9, 0.0, -3.8, 153.5]) + insertion_result = insertion_sort([1.0, -1.9, 0.0, -3.8, 153.5]) + bubble_result = bubble_sort([1.0, -1.9, 0.0, -3.8, 153.5]) + python_result = sorted([1.0, -1.9, 0.0, -3.8, 153.5]) + assert heap_result == insertion_result == bubble_result == python_result From 9f420f9056b367c05bd847e8c47e057112648ba0 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:10:29 +0300 Subject: [PATCH 23/33] Add __init__.py --- tests/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/__init__.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ + From f269274e85dc3e630e9f8b6606fe2c689077eca3 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:10:58 +0300 Subject: [PATCH 24/33] Delete src/hw_heapsort/tests directory --- src/hw_heapsort/tests/__init__.py | 1 - src/hw_heapsort/tests/tests_heapsort.py | 136 ------------------------ 2 files changed, 137 deletions(-) delete mode 100644 src/hw_heapsort/tests/__init__.py delete mode 100644 src/hw_heapsort/tests/tests_heapsort.py diff --git a/src/hw_heapsort/tests/__init__.py b/src/hw_heapsort/tests/__init__.py deleted file mode 100644 index 8b13789..0000000 --- a/src/hw_heapsort/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/hw_heapsort/tests/tests_heapsort.py b/src/hw_heapsort/tests/tests_heapsort.py deleted file mode 100644 index 31b9f8b..0000000 --- a/src/hw_heapsort/tests/tests_heapsort.py +++ /dev/null @@ -1,136 +0,0 @@ -import pytest -from ../sorts.py import heap_sort, bubble_sort, insertion_sort - -# обычные unit тесты и крайние случаи -@pytest.mark.empty -def test_heap_sort_empty(): - """Тест для пустого списка""" - result = heap_sort([]) - assert result == [] - - -@pytest.mark.single -def test_heap_sort_single(): - """Тест для списка из одного элемента""" - result = heap_sort([42]) - assert result == [42] - - -@pytest.mark.sorted -def test_heap_sort_sorted(): - """Тест для уже отсортированного списка""" - result = heap_sort([1, 2, 3, 4, 5]) - assert result == [1, 2, 3, 4, 5] - - -@pytest.mark.reversed -def test_heap_sort_reversed(): - """Тест для списка, отсортированного в обратном порядке""" - result = heap_sort([5, 4, 3, 2, 1]) - assert result == [1, 2, 3, 4, 5] - - -@pytest.mark.duplicates -def test_heap_sort_with_duplicates(): - """Тест для списка с дубликатами""" - result = heap_sort([1, 3, 1, 3, 2, 1, 1, 1, 2]) - assert result == [1, 1, 1, 1, 1, 2, 2, 3, 3] - -@pytest.mark.negative -def test_heap_sort_negative_num(): - """Тест с отрицательными числами""" - result = heap_sort([-5, -1, -3, -2, -181818, -4]) - assert result == [-181818, -5, -4, -3, -2, -1] - - -@pytest.mark.mixed -def test_heap_sort_mixed(): - """Тест с положительными и отрицательными числами""" - result = heap_sort([250000, -3, 5, -1, 2, -1000, 0, -2]) - assert result == [-1000, -3, -2, -1, 0, 2, 5, 250000] - - -@pytest.mark.float -def test_heap_sort_floats(): - """Тест с числами с плавающей точкой""" - result = heap_sort([3.6, 1.2, 4.8, 2.1, 0.5, 2.0]) - assert result == [0.5, 1.2, 2.0, 2.1, 3.6, 4.8] - -# тесты для сравнения heapsort и insertion sort и bubble sort -@pytest.mark.all_sorts_empty -def test_all_sorts_empty(): - """Тест для пустого списка""" - heap_result = heap_sort([]) - insertion_result = insertion_sort([]) - bubble_result = bubble_sort([]) - python_result = sorted([]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_single -def test_all_sorts_single(): - """Тест для списка из одного элемента""" - heap_result = heap_sort([52]) - insertion_result = insertion_sort([52]) - bubble_result = bubble_sort([52]) - python_result = sorted([52]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_sorted -def test_all_sorts_sorted(): - """Тест для уже отсортированного списка""" - heap_result = heap_sort([1,2,3]) - insertion_result = insertion_sort([1,2,3]) - bubble_result = bubble_sort([1,2,3]) - python_result = sorted([1,2,3]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_reversed -def test_all_sorts_reversed(): - """Тест для списка, отсортированного в обратном порядке""" - heap_result = heap_sort([5, 4, 3]) - insertion_result = insertion_sort([5, 4, 3]) - bubble_result = bubble_sort([5, 4, 3]) - python_result = sorted([5, 4, 3]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_duplicates -def test_all_sorts_with_duplicates(): - """Тест для списка с дубликатами""" - heap_result = heap_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) - insertion_result = insertion_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) - bubble_result = bubble_sort([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) - python_result = sorted([0, 0, 3, 5, 4, 5, 5, 3, 0, 0]) - assert heap_result == insertion_result == bubble_result == python_result - -@pytest.mark.all_sorts_negative -def test_all_sorts_negative_num(): - """Тест с отрицательными числами""" - heap_result = heap_sort([-762, -10, -387, -37072]) - insertion_result = insertion_sort([-762, -10, -387, -37072]) - bubble_result = bubble_sort([-762, -10, -387, -37072]) - python_result = sorted([-762, -10, -387, -37072]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_mixed -def test_all_sorts_mixed(): - """Тест с положительными и отрицательными числами""" - heap_result = heap_sort([100, -1, 0, -387, 153]) - insertion_result = insertion_sort([100, -1, 0, -387, 153]) - bubble_result = bubble_sort([100, -1, 0, -387, 153]) - python_result = sorted([100, -1, 0, -387, 153]) - assert heap_result == insertion_result == bubble_result == python_result - - -@pytest.mark.all_sorts_float -def test_all_sorts_floats(): - """Тест с числами с плавающей точкой""" - heap_result = heap_sort([1.0, -1.9, 0.0, -3.8, 153.5]) - insertion_result = insertion_sort([1.0, -1.9, 0.0, -3.8, 153.5]) - bubble_result = bubble_sort([1.0, -1.9, 0.0, -3.8, 153.5]) - python_result = sorted([1.0, -1.9, 0.0, -3.8, 153.5]) - assert heap_result == insertion_result == bubble_result == python_result From ba52bf62ba6bce894221f190aa17e50cd541d13f Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:11:52 +0300 Subject: [PATCH 25/33] Update path in heapsort-tests.yml --- .github/workflows/heapsort-tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/heapsort-tests.yml b/.github/workflows/heapsort-tests.yml index 1f99d34..2348612 100644 --- a/.github/workflows/heapsort-tests.yml +++ b/.github/workflows/heapsort-tests.yml @@ -19,7 +19,5 @@ jobs: - name: Run tests run: | - cd .. - cd src/hw_heapsort/tests python -m pytest tests_heapsort.py -v From 65ded4ce946625e1d719e584bbb3d0f25a161d63 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:21:13 +0300 Subject: [PATCH 26/33] Update path in heapsort-tests.yml --- .github/workflows/heapsort-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/heapsort-tests.yml b/.github/workflows/heapsort-tests.yml index 2348612..f5d5844 100644 --- a/.github/workflows/heapsort-tests.yml +++ b/.github/workflows/heapsort-tests.yml @@ -19,5 +19,5 @@ jobs: - name: Run tests run: | - python -m pytest tests_heapsort.py -v + python -m pytest tests/tests_heapsort.py -v From e6f020dca0cf65e44677ff79e6034dd5dd435b56 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:23:24 +0300 Subject: [PATCH 27/33] Update path in tests_heapsort.py --- tests/tests_heapsort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_heapsort.py b/tests/tests_heapsort.py index eba6405..f7ef1ef 100644 --- a/tests/tests_heapsort.py +++ b/tests/tests_heapsort.py @@ -1,5 +1,5 @@ import pytest -from src/hw_heapsort/sorts.py import heap_sort, bubble_sort, insertion_sort +from ..src.hw_heapsort.sorts.py import heap_sort, bubble_sort, insertion_sort # обычные unit тесты и крайние случаи @pytest.mark.empty From af9b2f8b0e06ce7ee95a73b0f8b5ed343a74f1d0 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:25:18 +0300 Subject: [PATCH 28/33] Add __init__.py to create package --- src/hw_heapsort/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/hw_heapsort/__init__.py diff --git a/src/hw_heapsort/__init__.py b/src/hw_heapsort/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/hw_heapsort/__init__.py @@ -0,0 +1 @@ + From acacf92e4e67671fb57c9f041d25ca867081075a Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:25:44 +0300 Subject: [PATCH 29/33] Add __init__.py to create a package --- src/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/__init__.py diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/__init__.py @@ -0,0 +1 @@ + From 001673da237e48735f5df64653644a028e7ca1f0 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:26:09 +0300 Subject: [PATCH 30/33] Update path in tests_heapsort.py --- tests/tests_heapsort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_heapsort.py b/tests/tests_heapsort.py index f7ef1ef..3402cf4 100644 --- a/tests/tests_heapsort.py +++ b/tests/tests_heapsort.py @@ -1,5 +1,5 @@ import pytest -from ..src.hw_heapsort.sorts.py import heap_sort, bubble_sort, insertion_sort +from src.hw_heapsort.sorts.py import heap_sort, bubble_sort, insertion_sort # обычные unit тесты и крайние случаи @pytest.mark.empty From ef1ca4f5402abb4d2330fa8ea80f3cab6744f111 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:28:01 +0300 Subject: [PATCH 31/33] Update path in tests_heapsort.py --- tests/tests_heapsort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_heapsort.py b/tests/tests_heapsort.py index 3402cf4..f7ef1ef 100644 --- a/tests/tests_heapsort.py +++ b/tests/tests_heapsort.py @@ -1,5 +1,5 @@ import pytest -from src.hw_heapsort.sorts.py import heap_sort, bubble_sort, insertion_sort +from ..src.hw_heapsort.sorts.py import heap_sort, bubble_sort, insertion_sort # обычные unit тесты и крайние случаи @pytest.mark.empty From fc02947edbc2b5a861e015d176da437b3f3d7029 Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:33:57 +0300 Subject: [PATCH 32/33] Update path in tests_heapsort.py --- tests/tests_heapsort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_heapsort.py b/tests/tests_heapsort.py index f7ef1ef..10f9781 100644 --- a/tests/tests_heapsort.py +++ b/tests/tests_heapsort.py @@ -1,5 +1,5 @@ import pytest -from ..src.hw_heapsort.sorts.py import heap_sort, bubble_sort, insertion_sort +from ..src.hw_heapsort.sorts import heap_sort, bubble_sort, insertion_sort # обычные unit тесты и крайние случаи @pytest.mark.empty From f017b7e87525bdc724a7308d2f3b00c52cf7447d Mon Sep 17 00:00:00 2001 From: DolzhenkoAlexa Date: Fri, 26 Dec 2025 13:34:31 +0300 Subject: [PATCH 33/33] Update path in tests_heapsort.py --- tests/tests_heapsort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_heapsort.py b/tests/tests_heapsort.py index 10f9781..0bc6d3a 100644 --- a/tests/tests_heapsort.py +++ b/tests/tests_heapsort.py @@ -1,5 +1,5 @@ import pytest -from ..src.hw_heapsort.sorts import heap_sort, bubble_sort, insertion_sort +from src.hw_heapsort.sorts import heap_sort, bubble_sort, insertion_sort # обычные unit тесты и крайние случаи @pytest.mark.empty