gluon/tests is in the source version..

On Wed, Sep 2, 2009 at 10:16 PM, Matthew <[email protected]> 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 <[email protected]> wrote:
> > Did you look into gluon/tests/ ?
> >
> > On Sep 2, 6:47 pm, Matthew <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to