Exemple #1
0
 def test_numbercomma(self):
     self._delete_target_file()
     self._create_random_comma_file(100, 10000)
     self.sorter.sort_file(self.__DATAFILE__, self.__TARGETFILE__,
                           comp=compare_num(parser_delimiter(",", 1)),
                           memory_safe=True, max_men=5000000)
     with open(self.__TARGETFILE__, 'r') as file:
         prev_line = file.readline()
         while prev_line:
             line = file.readline()
             if line:
                 self.assertTrue(float(prev_line.split(',')[1])
                                 <= float(line.split(',')[1]))
             prev_line = line
 def test_number_comma(self):
     self.__delete_target_file()
     self._create_random_comma_file(100, 10000)
     self.sorter.sort_file(self.__DATAFILE__,
                           dst_file=self.__TARGETFILE__,
                           comp=compare_num(parser_delimiter(",", 1)))
     with open(self.__TARGETFILE__, 'r') as file:
         prev_line = file.readline()
         while prev_line:
             line = file.readline()
             if line:
                 self.assertLessEqual(float(prev_line.split(',')[1]),
                                      float(line.split(',')[1]))
             prev_line = line
Exemple #3
0
 def test_big_file_10_perc(self):
     self._delete_target_file()
     total_rows = 10000000
     _create_fast_pseudo_random_regex_date_file(1000, total_rows,
                                                self.__DATAFILE__)
     data = self.sorter.sort_file(self.__DATAFILE__,
                                  comp=compare_num(parser_delimiter("##", 3)),
                                  memory_safe=True, avmemperc=0.1)
     prev_line = None
     size = 0
     for line in data:
         if prev_line:
             self.assertLessEqual(float(prev_line.split('##')[1]),
                                  float(line.split('##')[1]))
         prev_line = line
         size += 1
     self.assertEqual(total_rows, size)
     os.remove(self.__DATAFILE__)