import support # Key comparison in dicts for text-like keys class Wrapper(object): def __init__(self, content): self.content = content def __hash__(self): return hash(self.content) def __cmp__(self, other): if isinstance(other, Wrapper): return cmp(self.content, other.content) return cmp(self.content, other) dct = {"ABC": 1} ABC = Wrapper("ABC") try: dct[ABC] except KeyError: raise support.TestWarning("key comparison failed for a text-like key")