コード例 #1
0
 class Model(modelling.NamedParentable):
     _hidden_top = modelling.NamedParentable("_Top")
     _hidden_middle = modelling.NamedParentable("_Middle",
                                                parent=_hidden_top)
     _hidden_bottom = modelling.NamedParentable("_Bottom",
                                                parent=_hidden_middle)
     leaf = modelling.NamedParentable("Leaf", parent=_hidden_bottom)
コード例 #2
0
def test_basic_modelling() -> None:
    """Ensure basic inline modelling works.

    Without using class-based modelling, `e2e` modelled constructs should be
    entirely functional. This only requires that the user manually supplies the
    parent.
    """

    root = modelling.NamedParentable("Root")
    leaf = modelling.NamedParentable("Leaf", parent=root)

    # Ensure these still behave as their components do
    assert root.name == "Root"
    assert leaf.name == "Leaf"

    # Ensure proper linkage
    assert root.parent is None
    assert leaf.parent == root
コード例 #3
0
    class ClobberedModel(modelling.NamedParentable):
        # pylint: disable=super-init-not-called
        def __init__(self) -> None:
            self.custom_data = "foo"

        leaf = modelling.NamedParentable("Leaf")
コード例 #4
0
 class SubModel(modelling.NamedParentable):
     leaf = modelling.NamedParentable("Leaf")
コード例 #5
0
 class Model(modelling.NamedParentable):
     _hidden = modelling.NamedParentable("Hidden")
     leaf = modelling.NamedParentable("Leaf", parent=_hidden)
コード例 #6
0
 class Model(modelling.NamedParentable):
     leaf1 = modelling.NamedParentable("Leaf")
     leaf2 = modelling.NamedParentable("Leaf")
コード例 #7
0
 def leaf(self) -> modelling.NamedParentable:
     return modelling.NamedParentable("Leaf", parent=self._hidden)
コード例 #8
0
    class Model(modelling.NamedParentable):
        _hidden = modelling.NamedParentable("Hidden")

        @property
        def leaf(self) -> modelling.NamedParentable:
            return modelling.NamedParentable("Leaf", parent=self._hidden)