[openstack-dev] [horizon] mocking policy

Ana Krivokapic akrivoka at redhat.com
Wed Jun 4 12:56:28 UTC 2014


On 06/04/2014 02:41 PM, Radomir Dopieralski wrote:
> Hello,
>
> I'd like to start a discussion about the use of mocking libraries in
> Horizon's tests, in particular, mox and mock.
>
> As you may know, Mox is the library that has been used so far, and we
> have a lot of tests written using it. It is based on a similar Java
> library and does very strict checking, although its error reporting may
> leave something more to be desired.
>
> Mock is a more pythonic library, insluded in the stdlib of recent Python
> versions, but also available as a separate library for older pythons. It
> has a much more relaxed approach, allowing you to only test the things
> that you actually care about and to write tests that don't have to be
> rewritten after each and every refactoring.
>
> Some OpenStack projects, such as Nova, seem to have adopted an approach
> that favors Mock in newly written tests, but allows use of Mox for older
> tests, or when it's more suitable for the job.
>
> In Horizon we only use Mox, and Mock is not even in requirements.txt. I
> would like to propose to add Mock to requirements.txt and start using it
> in new tests where it makes more sense than Mox -- in particular, when
> we are writing unit tests only testing small part of the code.
>
> Thoughts?

Makes sense to me.

+1 for adding Mock to the requirements (test-requirements.txt rather
than requirements.txt, right?) and using it in newly written tests.

-- 
Regards,

Ana Krivokapic
Software Engineer
OpenStack team
Red Hat Inc.




More information about the OpenStack-dev mailing list