Ejemplo n.º 1
0
 def modifications_on_clone_do_not_alter_original(self):
     # Setup
     orig = Call(self.task,
                 called_as='foo',
                 args=[1, 2, 3],
                 kwargs={'key': 'val'})
     context = Context()
     context['setting'] = 'value'
     orig.context = context
     # Clone & tweak
     clone = orig.clone()
     newtask = Task(Mock(__name__='meh'))
     clone.task = newtask
     clone.called_as = 'notfoo'
     clone.args[0] = 7
     clone.kwargs['key'] = 'notval'
     clone.context['setting'] = 'notvalue'
     # Compare
     ok_(clone.task is not orig.task)
     eq_(orig.called_as, 'foo')
     eq_(clone.called_as, 'notfoo')
     eq_(orig.args, [1, 2, 3])
     eq_(clone.args, [7, 2, 3])
     eq_(orig.kwargs['key'], 'val')
     eq_(clone.kwargs['key'], 'notval')
     eq_(orig.context['setting'], 'value')
     eq_(clone.context['setting'], 'notvalue')
Ejemplo n.º 2
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'},
     )
     eq_(str(call), "<Call 'mytask', args: ('posarg1', 'posarg2'), kwargs: {'kwarg1': 'val1'}>") # noqa
Ejemplo n.º 3
0
 def returns_new_but_equivalent_object(self):
     orig = Call(self.task)
     clone = orig.clone()
     ok_(clone is not orig)
     ok_(clone == orig)
Ejemplo n.º 4
0
 def skips_aka_if_explicit_name_same_as_task_name(self):
     call = Call(self.task, called_as='mytask')
     eq_(str(call), "<Call 'mytask', args: (), kwargs: {}>")
Ejemplo n.º 5
0
 def includes_aka_if_explicit_name_given(self):
     call = Call(self.task, called_as='notmytask')
     eq_(str(
         call
     ), "<Call 'mytask' (called as: 'notmytask'), args: (), kwargs: {}>"
         )  # noqa
Ejemplo n.º 6
0
 def includes_task_name(self):
     call = Call(self.task)
     eq_(str(call), "<Call 'mytask', args: (), kwargs: {}>")