|
From: <sub...@co...> - 2005-11-19 22:38:06
|
Author: ianb
Date: 2005-11-19 22:37:57 +0000 (Sat, 19 Nov 2005)
New Revision: 1293
Modified:
FormEncode/trunk/docs/htmlfill.txt
FormEncode/trunk/formencode/validators.py
FormEncode/trunk/tests/test_doctests.py
Log:
Fixed doctests; fixed an error message
Modified: FormEncode/trunk/docs/htmlfill.txt
===================================================================
--- FormEncode/trunk/docs/htmlfill.txt 2005-11-18 21:57:50 UTC (rev 1292)
+++ FormEncode/trunk/docs/htmlfill.txt 2005-11-19 22:37:57 UTC (rev 1293)
@@ -39,6 +39,7 @@
>>> defaults = {'fname': 'Joe'}
>>> parser = htmlfill.FillingParser(defaults)
>>> parser.feed(form)
+ >>> parser.close()
>>> parser.text()
'<input type="text" name="fname" value="Joe">'
>>> parser.close()
Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py 2005-11-18 21:57:50 UTC (rev 1292)
+++ FormEncode/trunk/formencode/validators.py 2005-11-19 22:37:57 UTC (rev 1293)
@@ -116,7 +116,7 @@
...
Invalid: None is not a subclass of one of the types <type 'float'>, <type 'int'>
>>> cint2 = ConfirmType(type=int)
- >>> cint2.from_python(True)
+ >>> cint2(accept_python=False).from_python(True)
Traceback (most recent call last):
...
Invalid: True must be of the type <type 'int'>
@@ -143,7 +143,7 @@
if self.type:
if isinstance(self.type, list):
self.type = tuple(self.type)
- elif not isinstance(self.subclass, tuple):
+ elif not isinstance(self.type, tuple):
self.type = (self.type,)
self.validate_python = self.confirm_type
@@ -289,7 +289,7 @@
Traceback (most recent call last):
...
Invalid: Enter a value less than 5 characters long
- >>> max5.from_python('123456')
+ >>> max5(accept_python=False).from_python('123456')
Traceback (most recent call last):
...
Invalid: Enter a value less than 5 characters long
@@ -341,7 +341,7 @@
Traceback (most recent call last):
...
Invalid: Enter a value more than 5 characters long
- >>> min5.from_python('1234')
+ >>> min5(accept_python=False).from_python('1234')
Traceback (most recent call last):
...
Invalid: Enter a value more than 5 characters long
@@ -444,7 +444,13 @@
>>> cap = Regex(r'^[A-Z]+$')
>>> cap.to_python('ABC')
'ABC'
+
+ Note that ``.from_python()`` calls (in general) do not validate
+ the input:
+
>>> cap.from_python('abc')
+ 'abc'
+ >>> cap(accept_python=False).from_python('abc')
Traceback (most recent call last):
...
Invalid: The input is not valid
@@ -507,13 +513,15 @@
>>> PlainText.to_python('_this9_')
'_this9_'
>>> PlainText.from_python(' this ')
+ ' this '
+ >>> PlainText(accept_python=False).from_python(' this ')
Traceback (most recent call last):
...
Invalid: Enter only letters, numbers, or _ (underscore)
>>> PlainText(strip=True).to_python(' this ')
'this'
>>> PlainText(strip=True).from_python(' this ')
- ' this '
+ 'this'
"""
regex = r"^[a-zA-Z_\-0-9]*$"
Modified: FormEncode/trunk/tests/test_doctests.py
===================================================================
--- FormEncode/trunk/tests/test_doctests.py 2005-11-18 21:57:50 UTC (rev 1292)
+++ FormEncode/trunk/tests/test_doctests.py 2005-11-19 22:37:57 UTC (rev 1293)
@@ -1,8 +1,8 @@
import os, sys
if __name__ == '__main__':
- base = os.path.dirname(os.path.dirname(
- os.path.dirname(os.path.abspath(__file__))))
+ base = os.path.dirname(
+ os.path.dirname(os.path.abspath(__file__)))
sys.path.append(base)
try:
import doctest
|