test_englishcorpus.py 841 B

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