diff --git a/src/listwiz/sorting.py b/src/listwiz/sorting.py index a24744d..56b8ccc 100644 --- a/src/listwiz/sorting.py +++ b/src/listwiz/sorting.py @@ -21,7 +21,7 @@ def merge_sort(l): sorted_list """ # If there is a single item, the list is already sorted, return. - if len(l) == 1: + if len(l) <= 1: return l split = len(l) // 2 diff --git a/tests/test_sorting.py b/tests/test_sorting.py index 975c572..43f6dbb 100644 --- a/tests/test_sorting.py +++ b/tests/test_sorting.py @@ -16,9 +16,10 @@ def test_mergesort(): def test_mergesort_empty(): - # Stub for a test with empty lists, see issue #8 - pass - + # Test with empty list: + l = [] + res = lws.merge_sort(l) + assert res == [] @pytest.mark.parametrize( "input_list, expected",