0

Let's suppose I do some change to a function in the tests.py file, like monkey patching the clean method of some form...

When all the tests are finished, will that method still have associated the function I assigned?

A concrete example (to avoid captcha validation when testing):

from myapp.fields import ReCaptchaField
ReCaptchaField.clean = lambda x, y: y[0]

The same applies to adding/changing some field in the settings.py file...

4

1 回答 1

0

是的,它将保持关联。这就是猴子修补的好处/副作用/危险,在进程生命周期内更改默认行为。

于 2012-04-18T22:38:31.993 回答