def setclass():
    if verbose: print "Testing __class__ assignment..."
    class C(object): pass
    class D(object): pass
    class E(object): pass
    class F(D, E): pass
    for cls in C, D, E, F:
        for cls2 in C, D, E, F:
            x = cls()
            x.__class__ = cls2
            verify(x.__class__ is cls2)
            x.__class__ = cls
            verify(x.__class__ is cls)
    def cant(x, C):
        try:
            x.__class__ = C
        except TypeError:
            pass
        else:
            raise TestFailed, "shouldn't allow %r.__class__ = %r" % (x, C)
        try:
            delattr(x, "__class__")
        except __HOLE__:
            pass
        else:
            raise TestFailed, "shouldn't allow del %r.__class__" % x
    cant(C(), list)
    cant(list(), C)
    cant(C(), 1)
    cant(C(), object)
    cant(object(), list)
    cant(list(), object)
    class Int(int): __slots__ = []
    cant(2, Int)
    cant(Int(), int)
    cant(True, int)
    cant(2, bool)
    o = object()
    cant(o, type(1))
    cant(o, type(None))
    del o
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/test/test_descr.py/setclass