Re: [tryton-dev] Mock object

2014-07-04 Thread Nicolas Évrard
* Cédric Krier  [2014-06-23 18:37 +0200]: 

Hi,


Hello,


For the review [1], I started to use a Mock object for testing because
it was easier this way. I choose to use the backport of the Python3
unittest.mock [2] [3]. I think we should stick to this library if we
need to do some mocking in the unittest.


Yesterday I took some time[1] to use mocks on some code I have written
during the day.

Here are some observation I made:

   - it's really interesting to test only the small part of the code
 you've written. You can rely on the assumption that everything
 is working as expected it brings the true meaning of unit in
 unittest!

   - a lot of boilerplate code is needed to write a correct test

   - due to the amount of boilerplate code needed I am a bit afraid
 that the test will be difficult to maintain

   - patching object is awesome but nesting patch in with statements
 is a real indentation killer

All in all it's a very nice tool to have in our box because it makes
test more 'unitary' but there is some little annoyances (but I might
have missed the obvious).

[1]: No girlfriend at home and no world cup games to watch ;)

--
Nicolas Évrard - B2CK SPRL
E-mail/Jabber: nicolas.evr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/


signature.asc
Description: Digital signature


[tryton-dev] Mock object

2014-06-23 Thread Cédric Krier
Hi,

For the review [1], I started to use a Mock object for testing because
it was easier this way. I choose to use the backport of the Python3
unittest.mock [2] [3]. I think we should stick to this library if we
need to do some mocking in the unittest.


[1] http://codereview.tryton.org/9451004
[2] https://docs.python.org/3/library/unittest.mock.html
[3] http://pypi.python.org/pypi/mock

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: cedric.kr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/


pgpTXn66CdrgH.pgp
Description: PGP signature