[openstack-dev] [nova] Do we have some guidelines for mock, stub, mox when writing unit test?
Peter Feiner
peter at gridcentric.ca
Tue Nov 19 15:43:28 UTC 2013
A substantive reason for switching from mox to mock is the derelict
state of mox releases. There hasn't been a release of mox in three
years: the latest, mox-0.5.3, was released in 2010 [1, 2]. Moreover,
in the past 3 years, substantial bugs have been fixed in upstream mox.
For example, with the year-old fix to
https://code.google.com/p/pymox/issues/detail?id=16, a very nasty bug
in nova would have been caught by an existing test [3].
Alternatively, a copy of the upstream mox code could be added in-tree.
[1] mox releases: https://code.google.com/p/pymox/downloads/list
[2] mox on pypi: https://pypi.python.org/pypi/mox
[3] see comments 5 and 6 in https://bugs.launchpad.net/nova/+bug/1251792
On Wed, Nov 13, 2013 at 2:24 PM, Matt Riedemann
<mriedem at linux.vnet.ibm.com> wrote:
>
>
> On 11/12/2013 5:04 PM, Chuck Short wrote:
>>
>>
>>
>>
>> On Tue, Nov 12, 2013 at 4:49 PM, Mark McLoughlin <markmc at redhat.com
>> <mailto:markmc at redhat.com>> wrote:
>>
>> On Tue, 2013-11-12 at 16:42 -0500, Chuck Short wrote:
>> >
>> > Hi
>> >
>> >
>> > On Tue, Nov 12, 2013 at 4:24 PM, Mark McLoughlin
>> <markmc at redhat.com <mailto:markmc at redhat.com>>
>>
>> > wrote:
>> > On Tue, 2013-11-12 at 13:11 -0800, Shawn Hartsock wrote:
>> > > Maybe we should have some 60% rule... that is: If you
>> change
>> > more than
>> > > half of a test... you should *probably* rewrite the test
>> in
>> > Mock.
>> >
>> >
>> > A rule needs a reasoning attached to it :)
>> >
>> > Why do we want people to use mock?
>> >
>> > Is it really for Python3? If so, I assume that means we've
>> > ruled out the
>> > python3 port of mox? (Ok by me, but would be good to hear
>> why)
>> > And, if
>> > that's the case, then we should encourage whoever wants to
>> > port mox
>> > based tests to mock.
>> >
>> >
>> >
>> > The upstream maintainer is not going to port mox to python3 so we
>> have
>> > a fork of mox called mox3. Ideally, we would drop the usage of mox
>> in
>> > favour of mock so we don't have to carry a forked mox.
>>
>> Isn't that the opposite conclusion you came to here:
>>
>>
>> http://lists.openstack.org/pipermail/openstack-dev/2013-July/012474.html
>>
>> i.e. using mox3 results in less code churn?
>>
>> Mark.
>>
>>
>>
>> Yes that was my original position but I though we agreed in thread
>> (further on) that we would use mox3 and then migrate to mock further on.
>>
>> Regards
>> chuck
>>
>>
>> _______________________________________________
>> OpenStack-dev mailing list
>> OpenStack-dev at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>
> So it sounds like we're good with using mox for new tests again? Given Chuck
> got it into global-requirements here:
>
> https://github.com/openstack/requirements/commit/998dda263d7c7881070e3f16e4523ddcd23fc36d
>
> We can stave off the need to transition everything from mox to mock?
>
> I can't seem to find the nova blueprint to convert everything from mox to
> mock, maybe it was obsoleted already.
>
> Anyway, if mox(3) is OK and we don't need to use mock, it seems like we
> could add something to the developer guide here because I think this
> question comes up frequently:
>
> http://docs.openstack.org/developer/nova/devref/unit_tests.html
>
> Does anyone disagree?
>
> BTW, I care about this because I've been keeping in mind the mox/mock
> transition when doing code reviews and giving a -1 when new tests are using
> mox (since I thought that was a no-no now).
> --
>
> Thanks,
>
> Matt Riedemann
>
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
More information about the OpenStack-dev
mailing list