Comment 20 for bug 1266962

Julien Danjou (jdanjou) wrote :

There's a use case that is covered by this function that won't work with mock.

SQLAlchemy models can use something like a default value for colum with default=<func>. If <func> is set to datetime.datetime.utcnow, then it will be used to generate a default value. And no mocking can change that since the reference is already copied into the SQLAlchemy object – it's done at import time of our model module.

Here the time overriding mechanism is useful, since we can use default=timeutils.utcnow and use the override value to trick SQLAlchemy when it will call that function.