Beispiel #1
0
 def test_exceptions(self):
     with open("KEGG/enzyme.sample") as handle:
         with self.assertRaises(ValueError) as context:
             list(Enzyme.read(handle))
         self.assertTrue("More than one record found in handle" in str(context.exception))
         records = Enzyme.parse(handle)
         for i in range(0, 6):
             next(records)
         self.assertRaises(StopIteration, next, records)
Beispiel #2
0
 def test_exceptions(self):
     with open("KEGG/enzyme.sample") as handle:
         with self.assertRaises(ValueError) as context:
             list(Enzyme.read(handle))
         self.assertIn("More than one record found in handle",
                       str(context.exception))
         records = Enzyme.parse(handle)
         for i in range(0, 6):
             next(records)
         self.assertRaises(StopIteration, next, records)
def t_KEGG_Enzyme(testfiles):
    """Tests Bio.KEGG.Enzyme functionality."""
    for file in testfiles:
        fh = open(os.path.join("KEGG", file))
        print("Testing Bio.KEGG.Enzyme on " + file + "\n\n")
        records = Enzyme.parse(fh)
        for i, record in enumerate(records):
            print(record)

        fh.seek(0)
        if i == 0:
            print(Enzyme.read(fh))
        else:
            try:
                print(Enzyme.read(fh))
                assert False
            except ValueError as e:
                assert str(e) == 'More than one record found in handle'

        print("\n")
        fh.close()