On 14/10/10 13:50 +0200, Bertrand Chenal wrote: > Le Thu, 14 Oct 2010 12:14:37 +0200, > Cédric Krier <cedric.kr...@b2ck.com> a écrit : > > > On 13/10/10 17:26 +0200, Udo Spallek wrote: > > > Hello, > > > > > > please review my first Tryton test cases using the Proteus client > > > library at: http://codereview.appspot.com/2478041 > > > > I made a rewrite of this one using doctest to show the difference. > > > > http://codereview.appspot.com/2507041 > > > > IMO the "def test00XX" in the Udo version are not really needed and > obviously just add noise, without it and with some extra comments it > would be very close to the doctest version. > > Also, I think we will need tools like assertRaises, assertDictEqual, > etc (see [1]). They are not needed in the current example because those > are not finished: they create records but they do not test that results > are valid (like accounts balance, invoice amounts, etc).
You are still mixing unit testing and scenario concept. > The problem is that those assert* method cannot be used outside > unittest.testCase instances. OTOH relying on the doctest to validate > result is also a problem: > > this validates: > > """ > >>> x = {1:1, 2:2} > >>> x > {1: 1, 2: 2} > """ > > but this does not > > """ > >>> x = {2:2, 2:2} > >>> x > {2: 2, 1: 1} > """ > (wrong order of keys when dict is printed). > > > and this does not too: > > """ > >>> x = {1:1, 2:2} > >>> x > {1:1, 2:2} > """ > (missing space after ":"). The doc says you must test like this: >>> x = {1:1, 2:2} >>> x == {2:2, 1:1} True > Another problem of doctest is that it force you to write python code > inside strings which reminds me bad PHP scripts. This is because your mind see it like that. You can see the all as a new language (a little bit like WEB [1]). > Summary: We need assert* methods from unittest but unnitest layout of > tests is not good. Doctest validation is over-sensitive on > non-deterministic details and IMO best fit smaller tests. There is some trick when testing some kind of values but it is really not complicate to bypass. [1] http://en.wikipedia.org/wiki/WEB -- Cédric Krier B2CK SPRL Rue de Rotterdam, 4 4000 Liège Belgium Tel: +32 472 54 46 59 Email/Jabber: cedric.kr...@b2ck.com Website: http://www.b2ck.com/
pgpQmqgP6qJTj.pgp
Description: PGP signature