summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2021-09-08 22:51:46 -0500
committerptmcg <ptmcg@austin.rr.com>2021-09-08 22:51:46 -0500
commite2fb9f25431544b3c783e13e7fffc0e17bcf9fc8 (patch)
tree0a31fc24763af89c78441ed58242cb4625023924 /tests
parent6bdee2fec058493b4e1809aa25de3494f41e3627 (diff)
downloadpyparsing-git-e2fb9f25431544b3c783e13e7fffc0e17bcf9fc8.tar.gz
Add url expression to pyparsing_common (#249)
Diffstat (limited to 'tests')
-rw-r--r--tests/test_unit.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/test_unit.py b/tests/test_unit.py
index ba9c424..3b76cbe 100644
--- a/tests/test_unit.py
+++ b/tests/test_unit.py
@@ -5500,6 +5500,86 @@ class Test02_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase):
),
)
+ def testCommonUrl(self):
+ url_good_tests = """\
+ http://foo.com/blah_blah
+ http://foo.com/blah_blah/
+ http://foo.com/blah_blah_(wikipedia)
+ http://foo.com/blah_blah_(wikipedia)_(again)
+ http://www.example.com/wpstyle/?p=364
+ https://www.example.com/foo/?bar=baz&inga=42&quux
+ http://✪df.ws/123
+ http://userid:password@example.com:8080
+ http://userid:password@example.com:8080/
+ http://userid@example.com
+ http://userid@example.com/
+ http://userid@example.com:8080
+ http://userid@example.com:8080/
+ http://userid:password@example.com
+ http://userid:password@example.com/
+ http://142.42.1.1/
+ http://142.42.1.1:8080/
+ http://➡.ws/䨹
+ http://⌘.ws
+ http://⌘.ws/
+ http://foo.com/blah_(wikipedia)#cite-1
+ http://foo.com/blah_(wikipedia)_blah#cite-1
+ http://foo.com/unicode_(✪)_in_parens
+ http://foo.com/(something)?after=parens
+ http://☺.damowmow.com/
+ http://code.google.com/events/#&product=browser
+ http://j.mp
+ ftp://foo.bar/baz
+ http://foo.bar/?q=Test%20URL-encoded%20stuff
+ http://مثال.إختبار
+ """
+ success, report = ppc.url.runTests(url_good_tests)
+ self.assertTrue(success)
+
+ url_bad_tests = """\
+ http://
+ http://.
+ http://..
+ http://../
+ http://?
+ http://??
+ http://??/
+ http://#
+ http://##
+ http://##/
+ # skip: http://foo.bar?q=Spaces should be encoded
+ //
+ //a
+ ///a
+ ///
+ http:///a
+ foo.com
+ rdar://1234
+ h://test
+ http:// shouldfail.com
+
+ :// should fail
+ http://foo.bar/foo(bar)baz quux
+ ftps://foo.bar/
+ http://-error-.invalid/
+ # skip: http://a.b--c.de/
+ http://-a.b.co
+ http://a.b-.co
+ http://0.0.0.0
+ http://10.1.1.0
+ http://10.1.1.255
+ http://224.1.1.1
+ http://1.1.1.1.1
+ http://123.123.123
+ http://3628126748
+ http://.www.foo.bar/
+ # skip: http://www.foo.bar./
+ http://.www.foo.bar./
+ http://10.1.1.1
+ """
+ success, report = ppc.url.runTests(url_bad_tests, failure_tests=True)
+ self.assertTrue(success)
+
def testNumericExpressions(self):
# disable parse actions that do type conversion so we don't accidentally trigger