Mercurial > hg > urlmatch
annotate tests/doctest.txt @ 8:64935a05afdb
stub tests for diff, as yet unfinished
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 27 Jun 2011 11:14:10 -0700 |
parents | 0cd69fa6751c |
children | b02420253bfd |
rev | line source |
---|---|
2 | 1 Test urlmatch |
2 ============= | |
3 | |
4 The obligatory imports:: | |
5 | |
5 | 6 >>> from urlmatch import UrlMatcher |
2 | 7 |
8 Test matching:: | |
9 | |
10 >>> matcher = UrlMatcher('http://www.example.com/foo/bar/fleem') | |
11 >>> matcher.add('http://www.example.com/foo/blah') | |
12 >>> matcher.add('https://www.example.com/foo/') | |
13 >>> matcher.add('https://www.example.net/foo/') | |
14 >>> sorted(matcher.match('example.com/foo/bar')) | |
5 | 15 ['http://www.example.com/foo/bar/fleem'] |
2 | 16 >>> sorted(matcher.match('http://example.com/foo')) |
5 | 17 ['http://www.example.com/foo/bar/fleem', 'http://www.example.com/foo/blah'] |
2 | 18 >>> sorted(matcher.match('example.com')) |
5 | 19 ['http://www.example.com/foo/bar/fleem', 'http://www.example.com/foo/blah', 'https://www.example.com/foo/'] |
20 >>> sorted(matcher.match('example')) # -> example.* | |
21 ['http://www.example.com/foo/bar/fleem', 'http://www.example.com/foo/blah', 'https://www.example.com/foo/', 'https://www.example.net/foo/'] | |
2 | 22 |
6
0cd69fa6751c
add test for decomposition; stub diff, will have to move to 2-tuples to do this properly
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
23 Test decomposition:: |
0cd69fa6751c
add test for decomposition; stub diff, will have to move to 2-tuples to do this properly
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
24 |
0cd69fa6751c
add test for decomposition; stub diff, will have to move to 2-tuples to do this properly
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
25 >>> matcher = UrlMatcher() |
0cd69fa6751c
add test for decomposition; stub diff, will have to move to 2-tuples to do this properly
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
26 >>> sorted(matcher.decompose('http://www.example.com/foo').items()) |
0cd69fa6751c
add test for decomposition; stub diff, will have to move to 2-tuples to do this properly
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
27 [('domain', ['example', 'com', 'www']), ('path', ['foo']), ('scheme', 'http')] |
0cd69fa6751c
add test for decomposition; stub diff, will have to move to 2-tuples to do this properly
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
28 |
2 | 29 Test url diffs:: |
30 | |
5 | 31 >>> matcher = UrlMatcher() |