SimpleFormValidator obscures my docstrings (and doctests!)
"Matthew Wilson" <[email protected]> Wed, 10 Dec 2008 23:04:47 -0500
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
I wrote some doctests on a validator, then discovered that decorating
with SimpleFormValidator means that those doctests are on the inner
func attribute, not the outer object, so as far as I can tell, I can
run those doctests.
Trivial example:
>>> @SimpleFormValidator.decorate()
def f(value_dict, state, validator):
"""
Add a new key 'f' pointing to 99 to value_dict.
"""
value_dict['f'] = 99
...
>>> f().to_python({}, None)
{'f': 99}
Here's the problem: the docstring on the decorated f is really the
SimpleFormValidator's docstring:
>>> f.__doc__ == SimpleFormValidator.__doc__
True
Luckilly, the originally docstring is still alive, just hidden inside:
>>> print f.func.__doc__
Add a new key 'f' pointing to 99 to value_dict.
I'm trying to write some doctests for my validator f, but my test
runner (nose) doesn't run the doctests.
Any ideas about a solution?
Matt
--
Matthew Wilson
[email protected]
http://tplus1.com
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/