Exemple #1
0
 def test_empty_file(self):
     """
     make sure an empty file does not throw an error when reverse_readline
     is called this was a problem with an earlier implementation
     """
     with open(os.path.join(test_dir, "empty_file.txt")) as f:
         for idx, line in enumerate(reverse_readline(f)):
             raise ValueError("an empty file is being read!")
Exemple #2
0
 def test_empty_file(self):
     """
     make sure an empty file does not throw an error when reverse_readline
     is called this was a problem with an earlier implementation
     """
     with open(os.path.join(test_dir, "empty_file.txt")) as f:
         for idx, line in enumerate(reverse_readline(f)):
             raise ValueError("an empty file is being read!")
Exemple #3
0
 def test_reverse_readline(self):
     """
     We are making sure a file containing line numbers is read in reverse
     order, i.e. the first line that is read corresponds to the last line.
     number
     """
     with open(os.path.join(test_dir, "three_thousand_lines.txt")) as f:
         for idx, line in enumerate(reverse_readline(f)):
             self.assertEqual(int(line), self.NUMLINES - idx,
                              "read_backwards read {} whereas it should "
                              "have read {}".format(
                                  int(line), self.NUMLINES - idx))
Exemple #4
0
 def test_reverse_readline(self):
     """
     We are making sure a file containing line numbers is read in reverse
     order, i.e. the first line that is read corresponds to the last line.
     number
     """
     with open(os.path.join(test_dir, "three_thousand_lines.txt")) as f:
         for idx, line in enumerate(reverse_readline(f)):
             self.assertEqual(
                 int(line), self.NUMLINES - idx,
                 "read_backwards read {} whereas it should "
                 "have read {}".format(int(line), self.NUMLINES - idx))