diff test/test_templating.py @ 4009:e335ce40d6c8

Make URL matching code less matchy
author Richard Jones <richard@users.sourceforge.net>
date Mon, 01 Sep 2008 01:37:00 +0000
parents 13161539e5bd
children 797eacd945af
line wrap: on
line diff
--- a/test/test_templating.py	Mon Sep 01 00:43:02 2008 +0000
+++ b/test/test_templating.py	Mon Sep 01 01:37:00 2008 +0000
@@ -91,9 +91,13 @@
     def test_url_match(self):
         '''Test the URL regular expression in StringHTMLProperty.
         '''
-        def t(s, **groups):
+        def t(s, nothing=False, **groups):
             m = StringHTMLProperty.hyper_re.search(s)
-            self.assertNotEquals(m, None, '%r did not match'%s)
+            if nothing:
+                self.assertEquals(m, None, '%r matched'%s)
+                return
+            else:
+                self.assertNotEquals(m, None, '%r did not match'%s)
             d = m.groupdict()
             for g in groups:
                 self.assertEquals(d[g], groups[g], '%s %r != %r in %r'%(g, d[g],
@@ -103,10 +107,12 @@
         t('http://roundup.net/', url='http://roundup.net/')
         t('<HTTP://roundup.net/>', url='HTTP://roundup.net/')
         t('www.a.ex', url='www.a.ex')
+        t('foo.a.ex', nothing=True)
+        t('StDevValidTimeSeries.GetObservation', nothing=True)
         t('http://a.ex', url='http://a.ex')
         t('http://a.ex/?foo&bar=baz\\.@!$%()qwerty',
             url='http://a.ex/?foo&bar=baz\\.@!$%()qwerty')
-        t('www.net', url='www.net')
+        t('www.foo.net', url='www.foo.net')
         t('richard@com.example', email='richard@com.example')
         t('r@a.com', email='r@a.com')
         t('i1', **{'class':'i', 'id':'1'})

Roundup Issue Tracker: http://roundup-tracker.org/