Python: Problems mocking an instance
<p>I am having problem mocking an object to test a descriptor.</p>

<p>This is the code of the descriptor:</p>

<pre><code>class Text(object):
    def __init__(self, default_value=u'', validators=[]):
        self.validators = validators
        self._value = default_value

    def __set__(self, instance, value):
         for validator in self.validators:
               validator(value).validate()
</code></pre>

<p>this is the test:</p>

<pre><code>def test_text_validator_raises_exception(self):
   validator = Mock()
   validator.validate.side_effect = ValidationError()
   text = Text(validators=[validator])
   self.assertRaises( ValidationError, text__set__, (text, '') )
</code></pre>

<p><strong>Edit:</strong>
The function has () in the code I did a typo when copying the code.</p>

<p>The error I got was that <strong>set</strong>() takes exactly 3 arguments. But I noticed in the answers that I shouldn't pass a tuple as a last argument.</p>

<p>But It also isn't working when I called validator('').validate() inside the test function.</p>
