annotate tests/doctest.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 0cd69fa6751c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 Test urlmatch
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 =============
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 The obligatory imports::
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
5
6b99523536ee tests work
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
6 >>> from urlmatch import UrlMatcher
2
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 Test matching::
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 >>> matcher = UrlMatcher('http://www.example.com/foo/bar/fleem')
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 >>> matcher.add('http://www.example.com/foo/blah')
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 >>> matcher.add('https://www.example.com/foo/')
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 >>> matcher.add('https://www.example.net/foo/')
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 >>> sorted(matcher.match('example.com/foo/bar'))
5
6b99523536ee tests work
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
15 ['http://www.example.com/foo/bar/fleem']
2
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 >>> sorted(matcher.match('http://example.com/foo'))
5
6b99523536ee tests work
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
17 ['http://www.example.com/foo/bar/fleem', 'http://www.example.com/foo/blah']
2
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 >>> sorted(matcher.match('example.com'))
5
6b99523536ee tests work
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
19 ['http://www.example.com/foo/bar/fleem', 'http://www.example.com/foo/blah', 'https://www.example.com/foo/']
6b99523536ee tests work
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
20 >>> sorted(matcher.match('example')) # -> example.*
6b99523536ee tests work
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
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
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22
10
b02420253bfd add recomposition and a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
23 Test decomposition and recomposition::
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
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()
10
b02420253bfd add recomposition and a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
26 >>> decomposed = matcher.decompose('http://www.example.com/foo')
b02420253bfd add recomposition and a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
27 >>> sorted(decomposed.items())
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
28 [('domain', ['example', 'com', 'www']), ('path', ['foo']), ('scheme', 'http')]
10
b02420253bfd add recomposition and a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
29 >>> matcher.recompose(decomposed)
b02420253bfd add recomposition and a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
30 'http://www.example.com/foo'
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
31
2
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
32 Test url diffs::
20dde2687cfb stub doctests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
33
5
6b99523536ee tests work
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
34 >>> matcher = UrlMatcher()