def test_corpusContainsOnlyEmails(self): """Test reading the corpus with email messages only.""" corpus = Corpus(CORPUSDIR) # Exercise the SUT nitems = 0 for fname, contents in corpus.emails_as_string(): nitems += 1 # Validate the results self.assertEqual(self.expected[fname], contents, 'The read file contents are not equal to the expected contents.') self.assertEqual(nitems, NEMAILS, 'The emails_as_string() method did not return the right number of files.')
def test_corpusContainsOnlyEmails(self): """Test reading the corpus with email messages only.""" corpus = Corpus(CORPUS_DIR) # Exercise the SUT observed = {} for fname, contents in corpus.emails_as_string(): observed[fname] = contents # Verify the results self.assertEqual(len(self.expected), len(observed), 'The emails_as_string() method did not generate all the corpus files.') self.assertEqual(self.expected, observed, 'The read file contents are not equal to the expected contents.')
def test_corpusContainsAlsoSpecialFiles(self): """Test reading the corpus with special files.""" # Add a special file into the corpus dir save_file_to_corpus_dir( fname=SPECIAL_FILENAME, contents='fake', dirname=CORPUS_DIR) corpus = Corpus(CORPUS_DIR) # Exercise the SUT observed = {} for fname, contents in corpus.emails_as_string(): observed[fname] = contents # Verify the results self.assertEqual(len(self.expected), len(observed), 'The emails_as_string() method did not generate all the corpus files.') self.assertEqual(self.expected, observed, 'The read file contents are not equal to the expected contents.')
def test_corpusContainsOnlyEmails(self): """Test reading the corpus with email messages only.""" corpus = Corpus(CORPUS_DIR) # Exercise the SUT observed = {} for fname, contents in corpus.emails_as_string(): observed[fname] = contents # Verify the results self.assertEqual( len(self.expected), len(observed), 'The emails_as_string() method did not generate all the corpus files.' ) self.assertEqual( self.expected, observed, 'The read file contents are not equal to the expected contents.')
def test_corpusContainsAlsoSpecialFiles(self): """Test reading the corpus with special files.""" # Add a special file into the corpus dir fname = TRUTH_FILENAME contents = 'fake' save_file_to_corpus_dir(fname, contents, CORPUSDIR) # Exercise the SUT corpus = Corpus(CORPUSDIR) nitems = 0 for fname, contents in corpus.emails_as_string(): nitems += 1 # Validate results self.assertEqual(self.expected[fname], contents, 'The read file contents are not equal to the expected contents.') self.assertEqual(nitems, NEMAILS, 'The emails_as_string() method did not return the right number of files.')
def test_corpusContainsAlsoSpecialFiles(self): """Test reading the corpus with special files.""" # Add a special file into the corpus dir save_file_to_corpus_dir(fname=SPECIAL_FILENAME, contents='fake', dirname=CORPUS_DIR) corpus = Corpus(CORPUS_DIR) # Exercise the SUT observed = {} for fname, contents in corpus.emails_as_string(): observed[fname] = contents # Verify the results self.assertEqual( len(self.expected), len(observed), 'The emails_as_string() method did not generate all the corpus files.' ) self.assertEqual( self.expected, observed, 'The read file contents are not equal to the expected contents.')