def test_can_create_simple_cutplace_error(self): location = errors.Location('eggs.ods', has_cell=True, has_sheet=True) error = errors.CutplaceError('something must be something else', location) self.assertEqual(error.location, location) self.assertEqual( error.__str__(), 'eggs.ods (Sheet1!R1C1): something must be something else')
def test_can_create_cutplace_error_with_see_also_details(self): location = errors.Location('eggs.ods', has_cell=True, has_sheet=True) location.advance_line(3) location.advance_cell(2) location_of_cause = errors.Location('spam.ods', has_cell=True, has_sheet=True) cause = errors.CutplaceError('something must be something else', location_of_cause) error = errors.CutplaceError('cannot do something', location, cause.message, cause.location, cause) self.assertEqual(error.location, location) self.assertEqual(error.see_also_location, cause.location) self.assertEqual(error.cause, cause) self.assertEqual( error.__str__(), 'eggs.ods (Sheet1!R4C3): cannot do something ' + '(see also: spam.ods (Sheet1!R1C1): something must be something else)' )
def _create_name_to_class_map(base_class): assert base_class is not None result = {} # Note: we use a ``set`` of sub classes to ignore duplicates. for class_to_process in set(base_class.__subclasses__()): qualified_class_name = class_to_process.__name__ plain_class_name = qualified_class_name.split('.')[-1] clashing_class = result.get(plain_class_name) if clashing_class is not None: clashing_class_info = Cid._class_info(clashing_class) class_to_process_info = Cid._class_info(class_to_process) if clashing_class_info == class_to_process_info: # HACK: Ignore duplicate classes. Such classes can occur after `import_plugins` # has been called more than once. class_to_process = None else: raise errors.CutplaceError("clashing plugin class names must be resolved: %s and %s" % (clashing_class_info, class_to_process_info)) if class_to_process is not None: result[plain_class_name] = class_to_process return result