Exemple #1
0
        def can_clone_into_a_subclass(self):
            orig = Call(self.task)

            class MyCall(Call):
                pass

            clone = orig.clone(into=MyCall)
            assert clone == orig
            assert isinstance(clone, MyCall)
Exemple #2
0
        def can_be_given_extra_kwargs_to_clone_with(self):
            orig = Call(self.task)

            class MyCall(Call):
                def __init__(self, *args, **kwargs):
                    self.hooray = kwargs.pop("hooray")
                    super(MyCall, self).__init__(*args, **kwargs)

            clone = orig.clone(into=MyCall, with_={"hooray": "woo"})
            assert clone.hooray == "woo"
Exemple #3
0
 def includes_args_and_kwargs(self):
     call = Call(
         self.task,
         args=("posarg1", "posarg2"),
         # Single-key dict to avoid dict ordering issues
         kwargs={"kwarg1": "val1"},
     )
     expected = "<Call 'mytask', args: ('posarg1', 'posarg2'), kwargs: {'kwarg1': 'val1'}>"  # noqa
     assert str(call) == expected
Exemple #4
0
 def returns_new_but_equivalent_object(self):
     orig = Call(self.task)
     clone = orig.clone()
     assert clone is not orig
     assert clone == orig
Exemple #5
0
 def creates_a_new_Context_from_given_config(self):
     conf = Config(defaults={"foo": "bar"})
     c = Call(_).make_context(conf)
     assert isinstance(c, Context)
     assert c.foo == "bar"
Exemple #6
0
 def requires_config_argument(self):
     with raises(TypeError):
         Call(_).make_context()
Exemple #7
0
 def skips_aka_if_explicit_name_same_as_task_name(self):
     call = Call(self.task, called_as="mytask")
     assert str(call) == "<Call 'mytask', args: (), kwargs: {}>"
Exemple #8
0
 def includes_aka_if_explicit_name_given(self):
     call = Call(self.task, called_as="notmytask")
     expected = "<Call 'mytask' (called as: 'notmytask'), args: (), kwargs: {}>"  # noqa
     assert str(call) == expected
Exemple #9
0
 def is_first_posarg(self):
     assert Call(_).task is _
Exemple #10
0
 def may_be_given(self):
     assert Call(_, kwargs={"foo": "bar"}).kwargs == {"foo": "bar"}
Exemple #11
0
 def defaults_to_empty_dict(self):
     assert Call(_).kwargs == dict()
Exemple #12
0
 def may_be_given(self):
     assert Call(_, args=(1, 2, 3)).args == (1, 2, 3)
Exemple #13
0
 def defaults_to_empty_tuple(self):
     assert Call(_).args == tuple()
Exemple #14
0
 def may_be_given(self):
     assert Call(_, called_as="foo").called_as == "foo"
Exemple #15
0
 def defaults_to_None(self):
     assert Call(_).called_as is None
Exemple #16
0
 def includes_task_name(self):
     call = Call(self.task)
     assert str(call) == "<Call 'mytask', args: (), kwargs: {}>"
Exemple #17
0
 def is_required(self):
     with raises(TypeError):
         Call()