Hi Massimo,

If you would like some help developing a good regex, I have passable
skill in this area. I just need to have a list of conforming URLs vs.
non-conforming (to test against) and I can do the rest.


On Nov 3, 7:15 pm, mdipierro <[EMAIL PROTECTED]> wrote:

> fixed in trunk.

Thank you. Unfortunately, now it seems to be rejecting all valid
cases, e.g.:

http://www.benn.ca
http://benn.ca
http://amazon.com/books/
https://amazon.com/movies
rstp://idontknowthisprotocol
HTTP://allcaps.com
http://localhost
http://localhost/
http://localhost/hello
http://localhost/hello/
http://localhost:8080
http://localhost:8080/
http://localhost:8080/hello
http://localhost:8080/hello/
file:///C:/Documents%20and%20Settings/Jonathan/Desktop/view.py


I wrote a unit test for IS_URL(). Since I can't seem to attach
documents, I will paste it here:

'''
    Unit tests for IS_URL()
'''

import unittest
from gluon.validators import *


###############################################################################
class TestIsUrl(unittest.TestCase):

    x = IS_URL()


    def testInvalidUrls(self):
        urlsToCheck = ['fff',
                       'htp://invalid.com',
                       'http:hello.com',
                       'hTTp://www.benn.ca']

        failures = []

        for url in urlsToCheck:
            if self.x(url)[1] == None:
                failures.append('Incorrectly accepted: ' + url)

        if len(failures) > 0:
            self.fail(failures)

    def testValidUrls(self):

        urlsToCheck = ['http://www.benn.ca',
                       'http://benn.ca',
                       'http://amazon.com/books/',
                       'https://amazon.com/movies',
                       'rstp://idontknowthisprotocol',
                       'HTTP://allcaps.com',
                       'http://localhost',
                       'http://localhost/',
                       'http://localhost/hello',
                       'http://localhost/hello/',
                       'http://localhost:8080',
                       'http://localhost:8080/',
                       'http://localhost:8080/hello',
                       'http://localhost:8080/hello/',
                       'file:///C:/Documents%20and%20Settings/Jonathan/
Desktop/view.py']

        failures = []

        for url in urlsToCheck:
            if self.x(url)[1] != None:
                failures.append('Incorrectly rejected: ' + url)

        if len(failures) > 0:
            self.fail(failures)





###############################################################################
if __name__ == "__main__":
    unittest.main()



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
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