Bugs in URL validator
Felix Schwarz <felix.schwarz-S0/[email protected]>
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
The URL validator has the same problems as Email so I'm just sending the test cases. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ FormEncode-discuss mailing list FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/formencode-discuss
url_max_type_testcase.patch
(text/x-patch, 1.2 KB)
Index: tests/test_validators.py
===================================================================
--- tests/test_validators.py (Revision 3126)
+++ tests/test_validators.py (Arbeitskopie)
@@ -1,4 +1,4 @@
-from formencode.validators import String, UnicodeString, Invalid, Int
+from formencode.validators import String, UnicodeString, Invalid, Int, URL
from formencode.validators import DateConverter
from formencode.variabledecode import NestedVariables
from formencode.schema import Schema
@@ -127,3 +127,23 @@
else:
raise Exception("Shouldn't be valid data", values, start_values)
+
+def test_url_typecheck():
+ url = URL(check_exists=False, max=250)
+ try:
+ urlstring = ['']
+ url.to_python(urlstring)
+ raise Exception("Shouldn't be valid data", urlstring)
+ except Invalid, e:
+ assert 'The input must be a string' in str(e)
+
+
+def test_url_max():
+ url = URL(check_exists=False, max=250)
+ try:
+ urlstring = 'http://www.example.com/' + "x"*260
+ url.to_python(urlstring)
+ raise Exception("Shouldn't be valid data", urlstring)
+ except Invalid, e:
+ assert 'Enter a value less than 250 characters long' in str(e)
+