def test_dir():
    if verbose:
        print "Testing dir() ..."
    junk = 12
    vereq(dir(), ['junk'])
    del junk

    # Just make sure these don't blow up!
    for arg in 2, 2L, 2j, 2e0, [2], "2", u"2", (2,), {2:2}, type, test_dir:
        dir(arg)

    # Try classic classes.
    class C:
        Cdata = 1
        def Cmethod(self): pass

    cstuff = ['Cdata', 'Cmethod', '__doc__', '__module__']
    vereq(dir(C), cstuff)
    verify('im_self' in dir(C.Cmethod))

    c = C()  # c.__doc__ is an odd thing to see here; ditto c.__module__.
    vereq(dir(c), cstuff)

    c.cdata = 2
    c.cmethod = lambda self: 0
    vereq(dir(c), cstuff + ['cdata', 'cmethod'])
    verify('im_self' in dir(c.Cmethod))

    class A(C):
        Adata = 1
        def Amethod(self): pass

    astuff = ['Adata', 'Amethod'] + cstuff
    vereq(dir(A), astuff)
    verify('im_self' in dir(A.Amethod))
    a = A()
    vereq(dir(a), astuff)
    verify('im_self' in dir(a.Amethod))
    a.adata = 42
    a.amethod = lambda self: 3
    vereq(dir(a), astuff + ['adata', 'amethod'])

    # The same, but with new-style classes.  Since these have object as a
    # base class, a lot more gets sucked in.
    def interesting(strings):
        return [s for s in strings if not s.startswith('_')]

    class C(object):
        Cdata = 1
        def Cmethod(self): pass

    cstuff = ['Cdata', 'Cmethod']
    vereq(interesting(dir(C)), cstuff)

    c = C()
    vereq(interesting(dir(c)), cstuff)
    verify('im_self' in dir(C.Cmethod))

    c.cdata = 2
    c.cmethod = lambda self: 0
    vereq(interesting(dir(c)), cstuff + ['cdata', 'cmethod'])
    verify('im_self' in dir(c.Cmethod))

    class A(C):
        Adata = 1
        def Amethod(self): pass

    astuff = ['Adata', 'Amethod'] + cstuff
    vereq(interesting(dir(A)), astuff)
    verify('im_self' in dir(A.Amethod))
    a = A()
    vereq(interesting(dir(a)), astuff)
    a.adata = 42
    a.amethod = lambda self: 3
    vereq(interesting(dir(a)), astuff + ['adata', 'amethod'])
    verify('im_self' in dir(a.Amethod))

    # Try a module subclass.
    from types import ModuleType
    class M(ModuleType):
        pass
    minstance = M("m")
    minstance.b = 2
    minstance.a = 1
    names = [x for x in dir(minstance) if x not in ["__name__", "__doc__"]]
    vereq(names, ['__package__', 'a', 'b'])

    class M2(M):
        def getdict(self):
            return "Not a dict!"
        __dict__ = property(getdict)

    m2instance = M2("m2")
    m2instance.b = 2
    m2instance.a = 1
    vereq(m2instance.__dict__, "Not a dict!")
    try:
        dir(m2instance)
    except __HOLE__:
        pass

    # Two essentially featureless objects, just inheriting stuff from
    # object.
    vereq(dir(None), dir(Ellipsis))

    # Nasty test case for proxied objects
    class Wrapper(object):
        def __init__(self, obj):
            self.__obj = obj
        def __repr__(self):
            return "Wrapper(%s)" % repr(self.__obj)
        def __getitem__(self, key):
            return Wrapper(self.__obj[key])
        def __len__(self):
            return len(self.__obj)
        def __getattr__(self, name):
            return Wrapper(getattr(self.__obj, name))

    class C(object):
        def __getclass(self):
            return Wrapper(type(self))
        __class__ = property(__getclass)

    dir(C()) # This used to segfault
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/test/test_descr.py/test_dir