def run_function(self, f, card, exact): assert len(card) == len(exact), 'len(card)=%s len(exact)=%s' % (len(card), len(exact)) i = 0 fieldname = 'f' card = BDFCard(card) for i, exacti in enumerate(exact): if exacti == SyntaxError: with self.assertRaises(SyntaxError): msg = 'field=%r exact=%r' % (card.field(i), exacti) #print msg f(card, i, fieldname) else: value = f(card, i, fieldname) self.assertEqual(value, exacti) i += 1
def run_function_default(self, f, card, exact, default): fieldname = 'f' assert len(card) == len(exact), 'len(card)=%s len(exact)=%s' % (len(card), len(exact)) assert len(card) == len(default), 'len(card)=%s len(default)=%s' % (len(card), len(default)) i = 0 card = BDFCard(card) for i, exacti in enumerate(exact): defaulti = default[i] if exacti == SyntaxError: with self.assertRaises(exacti): msg = 'field=%r exact=%r default=%r' % (card.field(i), exacti, defaulti) #print msg f(card, i, fieldname, defaulti) else: value = f(card, i, fieldname, defaulti) self.assertEqual(value, exacti) i += 1