Skip to content

Commit

Permalink
Refactor diversity calculation tests for content bundling
Browse files Browse the repository at this point in the history
Consolidated and improved diversity calculation tests for content bundling, including a new test case for empty word lists.
  • Loading branch information
drew2a committed Apr 5, 2024
1 parent 72e95c5 commit 6f42e69
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ def test_calculate_diversity_min_word_len(min_word_length, diversity):
]


def test_calculate_diversity_no_words():
# Test that calculate_diversity returns 0 if there are no words in the content list.
content_list = [{'name': ''}]
assert calculate_diversity(content_list) == 0


@pytest.mark.parametrize('text, diversity', DIVERSITY_EXAMPLES)
def test_calculate_diversity(text, diversity):
# Test that calculate_diversity calculates diversity based on the text.
content_list = [{'name': text}]
assert calculate_diversity(content_list, min_word_length=3) == pytest.approx(diversity, abs=0.01)


def test_calculate_diversity_no_words():
# Test that calculate_diversity returns 0 if there are no words in the content list.
content_list = [{'name': ''}]
assert calculate_diversity(content_list) == 0

0 comments on commit 6f42e69

Please sign in to comment.