Example #1
0
def test_words_different_min_counts(writing_string, expected_count,
                                    expected_paragraph_count):
    """Check that it can detect different counts of words."""
    # check the summarized value and the size of the dictionary
    # --> implicit use of the min function, which is the default
    actual_count, actual_count_dictionary = fragments.count_words(
        writing_string)
    assert actual_count == expected_count
    assert len(actual_count_dictionary) == expected_paragraph_count
    # --> explicit use of the min function, which is now a parameter
    actual_count, actual_count_dictionary = fragments.count_words(
        writing_string, min)
    assert len(actual_count_dictionary) == expected_paragraph_count
    assert actual_count == expected_count
Example #2
0
def test_words_different_sum_counts(writing_string, expected_count):
    """Check that it can detect different counts of total words."""
    # only check the sum count
    # does not check size of dictionary as that was
    # checked in a previous parameterized test case
    actual_count, actual_count_dictionary = fragments.count_words(
        writing_string, sum)
    assert actual_count == expected_count
Example #3
0
def test_words_different_counts(writing_string, expected_count):
    """Check that it can detect different counts of words"""
    assert fragments.count_words(writing_string) == expected_count