コード例 #1
0
def test_lazy_attributes():
    for attr in ["resolver", "translate", "typeclass_of", "algos"]:
        assert hasattr(mg, attr)

    with pytest.raises(TypeError, match="does not have a registered type"):
        mg.typeclass_of(set())

    with pytest.raises(TypeError, match="does not have a registered type"):
        mg.type_of(set())

    with pytest.raises(TypeError, match="does not have a registered type"):
        mg.translate(set(), "unknown type")

    assert isinstance(mg.resolver, Resolver)
    assert isinstance(mg.algos, Namespace)
コード例 #2
0
ファイル: plugin.py プロジェクト: seibert/metagraph
    def translate(self, dst_type: Union[str, ConcreteType, "Wrapper"],
                  **props):
        import metagraph as mg

        # This uses the current default resolver
        return mg.translate(self, dst_type, **props)