Change in vdsm[master]: test: Replacing MonkeyPatch with mock.patch example

ybronhei at redhat.com ybronhei at redhat.com
Thu Apr 7 19:05:33 UTC 2016


Yaniv Bronhaim has posted comments on this change.

Change subject: test: Replacing MonkeyPatch with mock.patch example
......................................................................


Patch Set 3:

(2 comments)

https://gerrit.ovirt.org/#/c/55603/3/tests/network/netinfo_test.py
File tests/network/netinfo_test.py:

Line 114
Line 115
Line 116
Line 117
Line 118
> The conversion from mockeypatch to mock includes mockeypatch to None.
you can separate it to another patch with explanation why it is not needed any more in the commit msg. more appropriate


Line 102: 
Line 103:         for passed, operstate, expected in values:
Line 104:             with mock.patch('vdsm.netinfo.nics.io.open',
Line 105:                             lambda x: io.BytesIO(str(passed))), \
Line 106:                     mock.patch('vdsm.netinfo.nics.operstate',
> The original code was better. Having a way to monkey patch multiple modules
we do prefer to use the standard mock. i don't see any issue with this approach, its not uglier not prettier than using MonkeyPatch and it doesn't matter. the idea here is to use well documented and standard python mock library
Line 107:                                lambda x: operstate):
Line 108:                 self.assertEqual(nics.speed('fake_nic'), expected)
Line 109: 
Line 110:     @mock.patch('vdsm.netinfo.cache.netinfo.networks',


-- 
To view, visit https://gerrit.ovirt.org/55603
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I34ef99c00e7e2e4bbf13a52ec8471815e81d2a9e
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Edward Haas <edwardh at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Edward Haas <edwardh at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Petr Horáček <phoracek at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list