Mercurial > hg > urlmatch
annotate urlmatch.txt @ 10:b02420253bfd default tip
add recomposition and a test for it
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 28 Jun 2011 18:39:18 -0700 |
parents | 8d47894191a0 |
children |
rev | line source |
---|---|
0 | 1 urlmatch |
2 ======== | |
3 | |
8
64935a05afdb
stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
4 Test basic diff functionality:: |
64935a05afdb
stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
5 |
64935a05afdb
stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
6 >>> matcher = UrlMatcher() |
64935a05afdb
stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
7 >>> matcher.diff('http://www.example.com', 'http://example.com') |
64935a05afdb
stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
8 {'domain': [None, None, ('www', None)]} |
64935a05afdb
stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
9 >>> matcher.diff('http://example.com', 'https://example.com') |
64935a05afdb
stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
10 {'scheme': ('http', 'https')} |
64935a05afdb
stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
11 |
0 | 12 Test making a basic tree:: |
13 | |
14 >>> urlmatcher = URLmatcher() | |
15 >>> urls = ['http://example.com/foo/bar.html', | |
16 ... 'http://example.com/foo/baz.html', | |
17 ... 'http://example.com/foo/fleem.html'] | |
18 >>> urlmatcher.add(*urls) | |
19 >>> urlmatcher.tree() | |
20 ['http://example.com/foo/': ['bar.html', 'baz.html', 'fleem.html']] | |
21 | |
22 Now a more complex tree:: | |
23 | |
24 >>> urlmatcher = URLmatcher() | |
25 >>> urlmatcher.add(*['http://example.com/index.html', | |
26 ... 'https://example.com/, | |
27 ... 'http://gitcub.com/k0s']) | |
28 >>> urlmatcher.tree() | |
9 | 29 ['example.com': ['http://example.com/index.html', 'https://example.com'], |