Support python-mock versions later than about 1.1
Support python-mock versions later than about 1.1

It seems the two alternatives for python-mock's way of patching objects are not
enough; more recent versions have patch.object, so let's support that as well.
I think this is post 1.0.1, but not entirely sure.

Additionally, move the import and check for patcher at top level, so they're
not executed each time patch_object is called.

Side-note: it seems there are many ways we call patch object in the code, some
cleanup would be in order but that's left for another time.

Signed-off-by: Iustin Pop <acf83a5274f31a43af6b914614365999469c1a31@google.com>
Signed-off-by: Viktor Bachraty <a13ea37fcfcda126dc54f94389ded93f402eee93@google.com>
Reviewed-by: Viktor Bachraty <a13ea37fcfcda126dc54f94389ded93f402eee93@google.com>
(cherry picked from commit cd91e0fd60b7812659d8cbe8a3f5566dcb94967d)
Signed-off-by: Apollon Oikonomopoulos <ed81ed0a45ccd5c8869bda52e38353a6299ee39e@debian.org>

ganeti/ganeti,ganeti/ganeti,mbakke/ganeti,mbakke/ganeti,mbakke/ganeti,ganeti/ganeti