|
4 | 4 | from validators import url, ValidationFailure |
5 | 5 |
|
6 | 6 |
|
7 | | -@pytest.mark.parametrize(('address',), [ |
8 | | - ('http://foobar.dk', True), |
9 | | - ('http://foobar.dk', True), |
10 | | - ('http://foobar.museum/foobar', True), |
11 | | - ('http://127.0.0.1/foobar', True), |
12 | | - ('http://127.0.0.1:9000/fake', True), |
13 | | - ('http://localhost/foobar', False), |
14 | | - ('http://foobar', False), |
15 | | - ('htp://foobar.com', False), |
16 | | - ('http://foobar..com', False), |
17 | | - ('http://fo..com', False), |
18 | | - ('http://fo.com', True), |
| 7 | +@pytest.mark.parametrize('address', [ |
| 8 | + u'http://foobar.dk', |
| 9 | + u'http://foobar.museum/foobar', |
| 10 | + u'http://fo.com', |
| 11 | + u'http://foo.com/blah_blah', |
| 12 | + u'http://foo.com/blah_blah/', |
| 13 | + u'http://foo.com/blah_blah_(wikipedia)', |
| 14 | + u'http://foo.com/blah_blah_(wikipedia)_(again)', |
| 15 | + u'http://www.example.com/wpstyle/?p=364', |
| 16 | + u'https://www.example.com/foo/?bar=baz&inga=42&quux', |
| 17 | + u'http://✪df.ws/123', |
| 18 | + u'http://userid:password@example.com:8080', |
| 19 | + u'http://userid:password@example.com:8080/', |
| 20 | + u'http://userid@example.com', |
| 21 | + u'http://userid@example.com/', |
| 22 | + u'http://userid@example.com:8080', |
| 23 | + u'http://userid@example.com:8080/', |
| 24 | + u'http://userid:password@example.com', |
| 25 | + u'http://userid:password@example.com/', |
| 26 | + u'http://142.42.1.1/', |
| 27 | + u'http://142.42.1.1:8080/', |
| 28 | + u'http://➡.ws/䨹', |
| 29 | + u'http://⌘.ws', |
| 30 | + u'http://⌘.ws/', |
| 31 | + u'http://foo.com/blah_(wikipedia)#cite-1', |
| 32 | + u'http://foo.com/blah_(wikipedia)_blah#cite-1', |
| 33 | + u'http://foo.com/unicode_(✪)_in_parens', |
| 34 | + u'http://foo.com/(something)?after=parens', |
| 35 | + u'http://☺.damowmow.com/', |
| 36 | + u'http://code.google.com/events/#&product=browser', |
| 37 | + u'http://j.mp', |
| 38 | + u'ftp://foo.bar/baz', |
| 39 | + u'http://foo.bar/?q=Test%20URL-encoded%20stuff', |
| 40 | + u'http://مثال.إختبار', |
| 41 | + u'http://例子.测试', |
| 42 | + u'http://उदाहरण.परीक्षा', |
| 43 | + u'http://-.~_!$&\'()*+,;=:%40:80%2f::::::@example.com', |
| 44 | + u'http://1337.net', |
| 45 | + u'http://a.b-c.de', |
| 46 | + u'http://223.255.255.254', |
19 | 47 | ]) |
20 | 48 | def test_returns_true_on_valid_url(address): |
21 | 49 | assert url(address) |
22 | 50 |
|
23 | 51 |
|
24 | | -@pytest.mark.parametrize(('address',), [ |
25 | | - ('http://foobar',), |
26 | | - ('foobar.dk',), |
27 | | - ('http://127.0.0/asdf',), |
28 | | - ('http://foobar.d',), |
29 | | - ('http://foobar.12',), |
30 | | - ('http://localhost:abc/a',), |
| 52 | +@pytest.mark.parametrize('address', [ |
| 53 | + 'http://foobar', |
| 54 | + 'foobar.dk', |
| 55 | + 'http://127.0.0/asdf', |
| 56 | + 'http://foobar.d', |
| 57 | + 'http://foobar.12', |
| 58 | + 'http://foobar', |
| 59 | + 'htp://foobar.com', |
| 60 | + 'http://foobar..com', |
| 61 | + 'http://fo..com', |
| 62 | + 'http://', |
| 63 | + 'http://.', |
| 64 | + 'http://..', |
| 65 | + 'http://../', |
| 66 | + 'http://?', |
| 67 | + 'http://??', |
| 68 | + 'http://??/', |
| 69 | + 'http://#', |
| 70 | + 'http://##', |
| 71 | + 'http://##/', |
| 72 | + 'http://foo.bar?q=Spaces should be encoded', |
| 73 | + '//', |
| 74 | + '//a', |
| 75 | + '///a', |
| 76 | + '///', |
| 77 | + 'http:///a', |
| 78 | + 'foo.com', |
| 79 | + 'rdar://1234', |
| 80 | + 'h://test', |
| 81 | + 'http:// shouldfail.com', |
| 82 | + ':// should fail', |
| 83 | + 'http://foo.bar/foo(bar)baz quux', |
| 84 | + 'ftps://foo.bar/', |
| 85 | + 'http://-error-.invalid/', |
| 86 | + 'http://a.b--c.de/', |
| 87 | + 'http://-a.b.co', |
| 88 | + 'http://a.b-.co', |
| 89 | + 'http://0.0.0.0', |
| 90 | + 'http://10.1.1.0', |
| 91 | + 'http://10.1.1.255', |
| 92 | + 'http://224.1.1.1', |
| 93 | + 'http://1.1.1.1.1', |
| 94 | + 'http://123.123.123', |
| 95 | + 'http://3628126748', |
| 96 | + 'http://.www.foo.bar/', |
| 97 | + 'http://www.foo.bar./', |
| 98 | + 'http://.www.foo.bar./', |
| 99 | + 'http://10.1.1.1', |
| 100 | + 'http://10.1.1.254', |
31 | 101 | ]) |
32 | 102 | def test_returns_failed_validation_on_invalid_url(address): |
33 | 103 | assert isinstance(url(address), ValidationFailure) |
0 commit comments