Re: [web2py] Re: Bug and fix about IS_DATE_IN_RANGE()

2010-05-08 Thread Jonathan Lundell
On May 8, 2010, at 12:52 AM, Iceberg wrote:

 Thanks for the quick response and fix. But one more comment when
 talking about doctest. You current doctest cases does not qualified to
 catch the bug. You need to design cases for critical point. Besides,
 you need not use print in doctest.

Right. There are several examples elsewhere in the file that can be followed.

Ideally, one would create the failing test cases before fixing the bug.

 
 For example, the current trunk:
 
 v = IS_DATE_IN_RANGE(minimum=datetime.date(2008,1,1), \
 maximum=datetime.date(2009,12,31), \
 format=%m/%d/
 %Y,error_message=oops)
 
 print v('03/03/2008')
(datetime.date(2008, 3, 3), None)
 
 I would suggest:
 
 v = IS_DATE_IN_RANGE(minimum=datetime.date(2008,1,1), \
 maximum=datetime.date(2009,12,31), \
 format=%m/%d/
 %Y,error_message=oops)
 
 v('1/01/2008')
(datetime.date(2008, 1, 1), None)
 
 Might not be considered as a big deal, although. Just my $0.02
 
 Regards,
 Iceberg
 
 On May8, 7:39am, mdipierro mdipie...@cs.depaul.edu wrote:
 Done. I added one test each. we should have more tests in gluon/tests
 we have none, only doctests for validators.
 
 On May 7, 4:26 pm, Jonathan Lundell jlund...@pobox.com wrote:
 
 
 
 On May 7, 2010, at 9:30 AM, Iceberg wrote:
 
 Right now, IS_DATE_IN_RANGE(minimum=foo, maximum=bar) does NOT accept
 the given minimum nor maximum value. That is not the design intention
 according to error message. Please get rid off the two equal marks in
 IS_DATE_IN_RANGE.__call__().
 
 Same applies to IS_DATETIME_IN_RANGE.
 
 Anybody who patches this: please add the relevant doctests.




Re: [web2py] Re: Bug and fix about IS_DATE_IN_RANGE()

2010-05-07 Thread Jonathan Lundell
On May 7, 2010, at 4:39 PM, mdipierro wrote:

 Done. I added one test each. we should have more tests in gluon/tests
 we have none, only doctests for validators.

Yes, we should (though doctests are nice documentation for validators).

There's a plugin for nose that will run doctests along with unit tests.

 
 On May 7, 4:26 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On May 7, 2010, at 9:30 AM, Iceberg wrote:
 
 Right now, IS_DATE_IN_RANGE(minimum=foo, maximum=bar) does NOT accept
 the given minimum nor maximum value. That is not the design intention
 according to error message. Please get rid off the two equal marks in
 IS_DATE_IN_RANGE.__call__().
 
 Same applies to IS_DATETIME_IN_RANGE.
 
 Anybody who patches this: please add the relevant doctests.