def dynamics():
    if verbose: print "Testing class attribute propagation..."
    class D(object):
        pass
    class E(D):
        pass
    class F(D):
        pass
    D.foo = 1
    vereq(D.foo, 1)
    # Test that dynamic attributes are inherited
    vereq(E.foo, 1)
    vereq(F.foo, 1)
    # Test dynamic instances
    class C(object):
        pass
    a = C()
    verify(not hasattr(a, "foobar"))
    C.foobar = 2
    vereq(a.foobar, 2)
    C.method = lambda self: 42
    vereq(a.method(), 42)
    C.__repr__ = lambda self: "C()"
    vereq(repr(a), "C()")
    C.__int__ = lambda self: 100
    vereq(int(a), 100)
    vereq(a.foobar, 2)
    verify(not hasattr(a, "spam"))
    def mygetattr(self, name):
        if name == "spam":
            return "spam"
        raise AttributeError
    C.__getattr__ = mygetattr
    vereq(a.spam, "spam")
    a.new = 12
    vereq(a.new, 12)
    def mysetattr(self, name, value):
        if name == "spam":
            raise AttributeError
        return object.__setattr__(self, name, value)
    C.__setattr__ = mysetattr
    try:
        a.spam = "not spam"
    except __HOLE__:
        pass
    else:
        verify(0, "expected AttributeError")
    vereq(a.spam, "spam")
    class D(C):
        pass
    d = D()
    d.foo = 1
    vereq(d.foo, 1)

    # Test handling of int*seq and seq*int
    class I(int):
        pass
    vereq("a"*I(2), "aa")
    vereq(I(2)*"a", "aa")
    vereq(2*I(3), 6)
    vereq(I(3)*2, 6)
    vereq(I(3)*I(2), 6)

    # Test handling of long*seq and seq*long
    class L(long):
        pass
    vereq("a"*L(2L), "aa")
    vereq(L(2L)*"a", "aa")
    vereq(2*L(3), 6)
    vereq(L(3)*2, 6)
    vereq(L(3)*L(2), 6)

    # Test comparison of classes with dynamic metaclasses
    class dynamicmetaclass(type):
        pass
    class someclass:
        __metaclass__ = dynamicmetaclass
    verify(someclass != object)
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/test/test_descr.py/dynamics