def test_ports():
 tests = (('http://foo.com:8000', ('http://foo.com:8000', '')), ('http://foo.com:8000/', ('http://foo.com:8000/', '')), ('http://bar.com:xkcd', ('http://bar.com', ':xkcd')), ('http://foo.com:81/bar', ('http://foo.com:81/bar', '')), ('http://foo.com:', ('http://foo.com', ':')))
 def check(test, output):
  eq_(u'<a href="{0}" rel="nofollow">{0}</a>{1}'.format(*output), linkify(test))
 for (test, output) in tests:
  (yield (check, test, output))

def test_ports ( ) : tests = ( ( 'http://foo.com:8000' , ( 'http://foo.com:8000' , '' ) ) , ( 'http://foo.com:8000/' , ( 'http://foo.com:8000/' , '' ) ) , ( 'http://bar.com:xkcd' , ( 'http://bar.com' , ':xkcd' ) ) , ( 'http://foo.com:81/bar' , ( 'http://foo.com:81/bar' , '' ) ) , ( 'http://foo.com:' , ( 'http://foo.com' , ':' ) ) ) def check ( test , output ) : eq_ ( u'<a href="{0}" rel="nofollow">{0}</a>{1}' . format ( * output ) , linkify ( test ) ) for ( test , output ) in tests : ( yield ( check , test , output ) )
urls can contain port numbers .