Advertisement
zamotivator

Untitled

Sep 7th, 2012
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. class Compare(unittest.TestCase):    
  2.     def create_parser(self, expected, actual):
  3.         def create_parser(self, callback):
  4.             try:
  5.                 result = callback()
  6.                 return 'PARSER', result
  7.             with BaseException, e:
  8.                 return 'EXCEPTION', repr(e)
  9.         e_kind, e_parser = create_parser(expected)
  10.         a_kind, a_parser = create_parser(actual)
  11.         if e_kind == 'PARSER':
  12.             if a_kind == 'PARSER':
  13.                 return 'PARSER', e_parser, a_parser
  14.             else:
  15.                 self.fail('expected parser, but received exception: %s' % a_parser)
  16.         else:
  17.             if a_kind == 'PARSER':
  18.                 self.fail('expected exception %s, but received parser' % e_parser)
  19.             else:
  20.                 return 'EXCEPTION', e_parser, a_parser
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement