def test_write(self): """ Check if GFF3 lines are written properly to the output file. """ test_input = Reader(self.__input_file) with Writer(self.__output_file) as test_output: for record in test_input.records(): test_output.write(record) # compare the test output file to the original one with open(self.__input_file) as test_input: with open(self.__output_file) as test_output: for input_line, output_line in zip(test_input, test_output): self.assertEqual(input_line, output_line)
def test_records(self): """ Check if the parse reads a file in the GFF3 format in the correct way. """ # test against the correct input file with open(self.__correct_file) as gff_file: parser = Reader(gff_file) for record in parser.records(): self.assertIsInstance(record, Record) # check against an unsorted input file with open(self.__correct_file) as gff_file: parser = Reader(gff_file) with self.assertRaises(Gff3Error): for record in parser.records(check_order=True): self.assertIsInstance(record, Record) # test against incorrect input files for i in self.__incorrect_files: with open(i) as gff_file: parser = Reader(gff_file) with self.assertRaises(Gff3Error): for _ in parser.records(): pass
def test_records(self): """ Check if the parse reads a file in the GFF3 format in the correct way. """ # test against the correct input file parser = Reader(self.__correct_file) for record in parser.records(): self.assertIsInstance(record, Gff3Record) # test against incorrect input files for gff_file in self.__incorrect_files: parser = Reader(os.path.join(self.__incorrect_file_dir, gff_file)) with self.assertRaises(Gff3Error): for _ in parser.records(): pass