Esempio n. 1
0
def test_desc_from_pyobj():
    class A:
        pass

    class B(A):
        pass

    ds = DocStorage().from_dict({"A": A, "B": B})
    dsa = DocStorageAccessor(ds)
    assert dsa.desc_from_pyobj(A, "A") is ds.descs["A"]
    return ds
Esempio n. 2
0
def test_desc_from_pyobj():
    class A:
        pass

    class B(A):
        pass

    ds = DocStorage().from_dict({'A': A, 'B': B})
    dsa = DocStorageAccessor(ds)
    assert dsa.desc_from_pyobj(A, 'A') is ds.descs['A']
    return ds
Esempio n. 3
0
def test_bases():
    class A:
        pass

    class B:
        pass

    class C(A, B):
        pass

    ds = DocStorage().from_dict({"C": C, "B": B})
    dsa = DocStorageAccessor(ds)
    for desc in dsa.get_possible_base_classes("C"):
        assert desc is ds.descs["B"] or desc.is_degenerated
    return ds
Esempio n. 4
0
def test_method_origin():
    class A:
        def foo(self):
            pass

    class B(A):
        def bar(self):
            pass

    class C(B):
        pass

    ds = DocStorage().from_dict({"C": C, "B": B})
    dsa = DocStorageAccessor(ds)
    origin = dsa.get_method_origin("C.bar")
    assert origin is ds.descs["B"]
    return ds
Esempio n. 5
0
def test_method_origin():
    class A:
        def foo(self):
            pass

    class B(A):
        def bar(self):
            pass

    class C(B):
        pass

    ds = DocStorage().from_dict({'C': C, 'B': B})
    dsa = DocStorageAccessor(ds)
    origin = dsa.get_method_origin('C.bar')
    assert origin is ds.descs['B']
    return ds