Пример #1
0
def generic_string(value, seen):
    if hasattr(value, '__name__'):
        return value.__name__
    try:
        d = value.__dict__
    except AttributeError:
        if type(value) == object:
            return 'object()'
        else:
            return repr(value)
    if (reflection.unbind_method(type(value).__repr__) !=
            reflection.unbind_method(object.__repr__)):
        return repr(value)
    else:
        return '%s(%s)' % (value.__class__.__name__, ', '.join(
            '%s=%s' % (k2, show(v2, seen)) for k2, v2 in d.items()))
Пример #2
0
def generic_string(value, seen):
    if hasattr(value, "__name__"):
        return value.__name__
    try:
        d = value.__dict__
    except AttributeError:
        if type(value) == object:
            return u"object()"
        else:
            return repr(value)
    if reflection.unbind_method(type(value).__repr__) != reflection.unbind_method(object.__repr__):
        return repr(value)
    else:
        return u"%s(%s)" % (
            value.__class__.__name__,
            u", ".join(u"%s=%s" % (k2, show(v2, seen)) for k2, v2 in d.items()),
        )
Пример #3
0
def generic_string(value, seen):
    if hasattr(value, u('__name__')):
        return value.__name__
    try:
        d = value.__dict__
    except AttributeError:
        if type(value) == object:
            return u('object()')
        else:
            return repr(value)
    if (
        reflection.unbind_method(type(value).__repr__) !=
        reflection.unbind_method(object.__repr__)
    ):
        return repr(value)
    else:
        return u('%s(%s)') % (
            value.__class__.__name__,
            u(', ').join(
                u('%s=%s') % (
                    k2, show(v2, seen)
                ) for k2, v2 in d.items()
            )
        )
Пример #4
0
def test_unbind_distinguishes_overridden_functions():
    assert unbind_method(C().f) != unbind_method(A.f)
Пример #5
0
def test_unbind_distinguishes_different_functions():
    assert unbind_method(A.f) != unbind_method(A.g)
Пример #6
0
def test_unbind_gives_parent_class_function():
    assert unbind_method(B().f) == unbind_method(A.f)
Пример #7
0
def test_unbind_distinguishes_overridden_functions():
    assert unbind_method(C().f) != unbind_method(A.f)
Пример #8
0
def test_unbind_distinguishes_different_functions():
    assert unbind_method(A.f) != unbind_method(A.g)
Пример #9
0
def test_unbind_gives_parent_class_function():
    assert unbind_method(B().f) == unbind_method(A.f)