test_englishcorpus.py 780 B

1234567891011121314151617181920212223242526272829303132
  1. from ..englishcorpus import EnglishCorpus
  2. def test_corpus_has_length():
  3. corpus = EnglishCorpus()
  4. assert corpus
  5. def test_corpus_can_be_shuffled():
  6. corpus = EnglishCorpus()
  7. corpus.shuffle()
  8. def test_corpus_can_be_limited_to_phrases_shorter_than_specified():
  9. corpus = EnglishCorpus(max_length=100)
  10. assert corpus
  11. def test_corpus_can_be_limited_to_phrases_longer_than_specified():
  12. corpus = EnglishCorpus(min_length=100)
  13. assert corpus
  14. def test_corpus_produces_random_sequence():
  15. corpus = EnglishCorpus()
  16. choices = [corpus.random_sentence() for _ in range(2)]
  17. assert len(choices) == len(set(choices))
  18. def test_corpus_produces_list_of_random_sentences():
  19. corpus = EnglishCorpus()
  20. assert len(corpus.random_sentences(5)) == 5