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)
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
class ClobberedModel(modelling.NamedParentable): # pylint: disable=super-init-not-called def __init__(self) -> None: self.custom_data = "foo" leaf = modelling.NamedParentable("Leaf")
class SubModel(modelling.NamedParentable): leaf = modelling.NamedParentable("Leaf")
class Model(modelling.NamedParentable): _hidden = modelling.NamedParentable("Hidden") leaf = modelling.NamedParentable("Leaf", parent=_hidden)
class Model(modelling.NamedParentable): leaf1 = modelling.NamedParentable("Leaf") leaf2 = modelling.NamedParentable("Leaf")
def leaf(self) -> modelling.NamedParentable: return modelling.NamedParentable("Leaf", parent=self._hidden)
class Model(modelling.NamedParentable): _hidden = modelling.NamedParentable("Hidden") @property def leaf(self) -> modelling.NamedParentable: return modelling.NamedParentable("Leaf", parent=self._hidden)