The book example is not precisely what I consider good testing in that you really can't reason whether the results are correct or not (I personally haven't read that whole book and counted all the words). For that functionality, my tests would look like
def test_word_counts():
book_text = "hello"
assert word_count(book_text, "hello") == 1
and so on. It is, however, a good showcase for having some resource you don't want to acquire multiple times. So, I think it would suffice to add a box somewhere saying that this is not an ideal approach for this specific problem. Do you agree?
The book example is not precisely what I consider good testing in that you really can't reason whether the results are correct or not (I personally haven't read that whole book and counted all the words). For that functionality, my tests would look like
and so on. It is, however, a good showcase for having some resource you don't want to acquire multiple times. So, I think it would suffice to add a box somewhere saying that this is not an ideal approach for this specific problem. Do you agree?