I'll look into their documentation more (strange error). Thank you for all of your help!
On Sep 5, 5:06 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > It must be a doctest then. No idea. > > On Sep 5, 3:00 pm, Matthew <matthew.g.nor...@gmail.com> wrote: > > > Unfortunately not - they both have exactly one space between the comma > > and > > "None". > > > File "validators.py", line 15, in __main__.IS_NOT_WHITESPACE > > Failed example: > > IS_NOT_WHITESPACE()(' spaces in between and on end ') > > Expected: > > ('spaces in between and on end', None) > > Got: > > ('spaces in between and on end', None) > > > On Sep 4, 10:08 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > could it be the number of spaces between the , and the None? > > > > On Sep 4, 6:17 am, Matthew <matthew.g.nor...@gmail.com> wrote: > > > > > Perhaps I don't understand doctests fully, but isn't all output from > > > > them converted to string anyway? You're essentially checking print > > > > statements from the shell, right? > > > > > For example, here is the IS_MATCH validator's doctests: > > > > > >>> IS_MATCH('.+')('hello') > > > > ('hello', None) > > > > > >>> IS_MATCH('.+')('') > > > > ('', 'invalid expression!') > > > > > And here is a problematic doctest from my IS_NOT_WHITESPACE validator > > > > (extended from IS_NOT_EMPTY): > > > > > >>> IS_NOT_WHITESPACE()(' spaces in between and on end ') > > > > ('spaces in between and on end', None) > > > > > The former evaluates fine, but the latter gives the error listed > > > > earlier in this thread. > > > > > On Sep 3, 9:15 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > Could it be one is a tuple and one is a string containing a > > > > > representation of the same tuple? > > > > > > On Sep 3, 7:34 pm, Matthew <matthew.g.nor...@gmail.com> wrote: > > > > > > > Thank you for the resource. I did check out the files there, but > > > > > > there isn't one that is dedicated to testing the Validators. Only > > > > > > "validators.py" contains some doctests. > > > > > > > I added some more tests to my example. What is truly weird is that > > > > > > it > > > > > > is failing on another test now, even though the "Got" and "Expected" > > > > > > values are identical: > > > > > > > File "validators.py", line 12, in __main__.IS_NOT_WHITESPACE > > > > > > Failed example: > > > > > > IS_NOT_WHITESPACE()(' spaces in between and on end ') > > > > > > Expected: > > > > > > ('spaces in between and on end', None) > > > > > > Got: > > > > > > ('spaces in between and on end', None) > > > > > > > Is there a doctest quirk that I do not know of? > > > > > > > Thank you again for the help, > > > > > > Matthew > > > > > > > On Sep 3, 1:33 am, Yarko Tymciurak <yark...@gmail.com> wrote: > > > > > > > > btw - you can browse the current source tree online - > > > > > > > >http://bazaar.launchpad.net/~mdipierro/web2py/devel/files > > > > > > > > On Thu, Sep 3, 2009 at 12:32 AM, Yarko Tymciurak > > > > > > > <yark...@gmail.com> wrote: > > > > > > > > gluon/tests is in the source version.. > > > > > > > > > On Wed, Sep 2, 2009 at 10:16 PM, Matthew > > > > > > > > <matthew.g.nor...@gmail.com>wrote: > > > > > > > > >> I'm not sure I understand. I don't see a gluon/tests/ folder > > > > > > > >> in > > > > > > > >> web2py and the <application>/tests/ folder is not populated > > > > > > > >> for the > > > > > > > >> sample apps. I looked at the original source of your official > > > > > > > >> "validators.py" as a model for the extended class and its > > > > > > > >> doctests. > > > > > > > > >> On Sep 2, 9:45 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > >> > Did you look into gluon/tests/ ? > > > > > > > > >> > On Sep 2, 6:47 pm, Matthew <matthew.g.nor...@gmail.com> > > > > > > > >> > wrote: > > > > > > > > >> > > I am trying to extend the IS_NOT_EMPTY validator to strip > > > > > > > >> > > out > > > > > > > >> > > whitespace before submitting. I have two questions (code > > > > > > > >> > > posted after > > > > > > > >> > > questions): > > > > > > > > >> > > 1. How can I test the custom message constructor? Right > > > > > > > >> > > now I always > > > > > > > >> > > get the "expected 2 arguments, got 3" error message? > > > > > > > >> > > 2. I am using doctests and can't tell the difference > > > > > > > >> > > between > > > > > > > >> > > "Expected" and "Got" in this test: > > > > > > > >> > > ********************************************************************** > > > > > > > >> > > File "validators.py", line 14, in > > > > > > > >> > > __main__.IS_NOT_WHITESPACE > > > > > > > >> > > Failed example: > > > > > > > >> > > IS_NOT_WHITESPACE()(' ') > > > > > > > >> > > Expected: > > > > > > > >> > > ('', 'cannot be empty!') > > > > > > > >> > > Got: > > > > > > > >> > > ('', 'cannot be empty!') > > > > > > > >> > > ********************************************************************** > > > > > > > >> > > 1 items had failures: > > > > > > > >> > > 1 of 4 in __main__.IS_NOT_WHITESPACE > > > > > > > >> > > ***Test Failed*** 1 failures. > > > > > > > > >> > > SOURCE CODE > > > > > > > > >> > > from gluon.validators import IS_NOT_EMPTY > > > > > > > >> > > import string > > > > > > > > >> > > class IS_NOT_WHITESPACE(IS_NOT_EMPTY): > > > > > > > >> > > """ > > > > > > > >> > > Example:: > > > > > > > >> > > INPUT(_type='text', _name='name', > > > > > > > >> > > requires=IS_NOT_WHITESPACE > > > > > > > >> > > ()) > > > > > > > > >> > > IS_NOT_WHITESPACE inherits from the IS_NOT_EMPTY > > > > > > > >> > > validator. It > > > > > > > >> > > trims the > > > > > > > >> > > argument, a string, of whitespace before validating: > > > > > > > > >> > > >>> IS_NOT_WHITESPACE()(' ') > > > > > > > >> > > ('', 'cannot be empty!') > > > > > > > >> > > >>> IS_NOT_WHITESPACE()(' ') > > > > > > > >> > > ('', 'cannot be empty!') > > > > > > > >> > > >>> IS_NOT_WHITESPACE()(' \t\r') > > > > > > > >> > > ('', 'cannot be empty!') > > > > > > > >> > > >>> IS_NOT_WHITESPACE()(string.whitespace) > > > > > > > >> > > ('', 'cannot be empty!') > > > > > > > >> > > """ > > > > > > > > >> > > def __call__(self, value): > > > > > > > >> > > return IS_NOT_EMPTY.__call__(self, value.strip()) > > > > > > > > >> > > # Allow doctests to be run if this file is called by > > > > > > > >> > > python. For > > > > > > > >> > > example: > > > > > > > >> > > # python validators.py > > > > > > > >> > > if __name__=='__main__': > > > > > > > >> > > import doctest > > > > > > > >> > > doctest.testmod() > > > > > > > > >> > > END SOURCECODE > > > > > > > > >> > > Thanks, > > > > > > > >> > > Matthew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---