def sibling_subcollections_ignored(self): inner = Collection("inner", self.task) inner.configure({"foo": "hi there"}) inner2 = Collection("inner2", Task(_func, name="task2")) inner2.configure({"foo": "nope"}) root = Collection(inner, inner2) assert root.configuration("inner.task")["foo"] == "hi there" assert root.configuration("inner2.task2")["foo"] == "nope"
def raises_ValueError_if_no_name_found(self): # Can't use a lambda here as they are technically real functions. class Callable(object): def __call__(self): pass with raises(ValueError): self.c.add_task(Task(Callable()))
def setup(self): self.root = Collection() self.task = Task(_func, name="task")
def honors_own_default_task_with_no_args(self): t = Task(_func, default=True) self.c.add_task(t) assert self.c[""] == t
def honors_aliases_in_own_tasks(self): t = Task(_func, aliases=["bar"]) self.c.add_task(t, "foo") assert self.c["bar"] == t
def raises_ValueError_on_multiple_defaults(self): t1 = Task(_func, default=True) t2 = Task(_func, default=True) self.c.add_task(t1, "foo") with raises(ValueError): self.c.add_task(t2, "bar")
def prefers_task_name_attr_over_function_name(self): self.c.add_task(Task(_func, name="notfunc")) assert "notfunc" in self.c assert "_func" not in self.c
def prefers_name_kwarg_over_task_name_attr(self): self.c.add_task(Task(_func, name="notfunc"), name="yesfunc") assert "yesfunc" in self.c assert "notfunc" not in self.c