class GeneTest(unittest.TestCase): def setUp(self): self.gene = Gene(1) self.errorformatter = MockErrorFormatter() self.badformatter = MockBadHTMLFormatter() db = bglib.doc.mock.DataBaseMock() self.goodformatter = bglib.doc.bgwiki.Formatter(db) def get_text_test(self): self.assert_(self.gene.get_text() in 'gtac') def format_bool_test(self): self.assertFalse(self.gene.format(self.errorformatter)) def format_error_test(self): e = self.gene.format(self.errorformatter) self.assert_(isinstance(e, FormatError)) self.assert_(isinstance(e.exception, Exception)) self.assertEqual(str(e.exception), '''MockErrorFormatter's mock AssertionError''') self.assert_('''bglib/doc/fuzzing.py", line 59, in format\n formatter.parse(text)\n''' in e.stacktrace) self.assert_('''bglib/doc/fuzzing_test.py", line 16, in parse\n raise AssertionError, "MockErrorFormatter's mock AssertionError"\n''' in e.stacktrace) def parse_error_test(self): e = self.gene.format(self.badformatter) self.assert_(e) e = self.gene.verify() self.assert_(isinstance(e.exception, Exception)) self.assert_(str(e.exception).startswith('mismatched tag: line ')) def ok_test(self): e = self.gene.format(self.goodformatter) self.assert_(e) e = self.gene.verify() self.assert_(e) def fork_test(self): pass
def setUp(self): self.gene = Gene(1) self.errorformatter = MockErrorFormatter() self.badformatter = MockBadHTMLFormatter() db = bglib.doc.mock.DataBaseMock() self.goodformatter = bglib.doc.bgwiki.Formatter(db)