Mercurial > hg > urlmatch
view 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 |
line wrap: on
line source
Test urlmatch ============= The obligatory imports:: >>> from urlmatch import UrlMatcher Test matching:: >>> matcher = UrlMatcher('http://www.example.com/foo/bar/fleem') >>> matcher.add('http://www.example.com/foo/blah') >>> matcher.add('https://www.example.com/foo/') >>> matcher.add('https://www.example.net/foo/') >>> sorted(matcher.match('example.com/foo/bar')) ['http://www.example.com/foo/bar/fleem'] >>> sorted(matcher.match('http://example.com/foo')) ['http://www.example.com/foo/bar/fleem', 'http://www.example.com/foo/blah'] >>> sorted(matcher.match('example.com')) ['http://www.example.com/foo/bar/fleem', 'http://www.example.com/foo/blah', 'https://www.example.com/foo/'] >>> sorted(matcher.match('example')) # -> example.* ['http://www.example.com/foo/bar/fleem', 'http://www.example.com/foo/blah', 'https://www.example.com/foo/', 'https://www.example.net/foo/'] Test decomposition:: >>> matcher = UrlMatcher() >>> sorted(matcher.decompose('http://www.example.com/foo').items()) [('domain', ['example', 'com', 'www']), ('path', ['foo']), ('scheme', 'http')] Test url diffs:: >>> matcher = UrlMatcher()