Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def __init__(self):
- super(Compare, self).__init__()
- self._init_create()
- def _init_create(self):
- def expected_parser_received_exception(expected, actual):
- self.fail(msg='%s: expected parser, but received exception: %s' % (self.name, actual))
- def expected_exception_received_parser(expected, actual):
- self.fail(msg='%s: ')
- def both_exception(expected, actual):
- self.assertEquals(expected = actual, msg="expected exception '%s', but received '%s'" % (expected, actual))
- self._create = {}
- self._create[('PARSER', 'PARSER')] = self.parse_args
- self._create[('PARSER', 'EXCEPTION')] = expected_parser_received_exception
- self._create[('EXCEPTION', 'PARSER')] = expected_exception_received_parser
- self._create[('EXCEPTION', 'EXCEPTION')] = both_exception
- def check_parser(self, expected, actual):
- def create_parser(self, callback):
- try:
- result = callback()
- return 'PARSER', result
- with BaseException, e:
- return 'EXCEPTION', repr(e)
- expected_kind, expected_result = create_parser(expected)
- actual_kind, actual_result = create_parser(actual)
- self._create[(expected_kind, actual_kind)](expected_result, actual_result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement