def testBadCharsInUrl(self): s = ur'abc http://d.e.f?<a>+"b"|foo ghi' f = Linker(s, 0) frags, next = f.apply() self.assertEqual(u"".join(frags), u'abc <a href="http://d.e.f?<a>+"b"">foo</a>') self.assertEqual(next, s.index(" ghi"))
def testInnerParens(self): s = ur"abc http://wiki/Foo_(Bar) ghi" f = Linker(s, 0) frags, next = f.apply() self.assertEqual(u"".join(frags), u'abc <a href="http://wiki/Foo_(Bar)">http://wiki/Foo_(Bar)</a>') self.assertEqual(next, s.index(" ghi"))
def testUnknownProtocolClass(self): s = ur"abc zox://wiki/Foo ghi" f = Linker(s, 0) frags, next = f.apply() self.assertEqual(u"".join(frags), u'abc <a href="zox://wiki/Foo" class="unknown">zox://wiki/Foo</a>') self.assertEqual(next, s.index(" ghi"))
def testPunctuationAndName(self): s = ur"abc http://d.e.f?ghi!|foo. ghi" f = Linker(s, 0) frags, next = f.apply() self.assertEqual(u"".join(frags), u'abc <a href="http://d.e.f?ghi!">foo.</a>') self.assertEqual(next, s.index(" ghi"))
def testOuterParensAndDot(self): s = ur"abc (http://d.e.f). ghi" f = Linker(s, 0) frags, next = f.apply() self.assertEqual(u"".join(frags), u'abc (<a href="http://d.e.f">http://d.e.f</a>') self.assertEqual(next, s.index("). ghi"))
def testComma(self): s = ur"abc http://d.e.f, ghi" f = Linker(s, 0) frags, next = f.apply() self.assertEqual(u"".join(frags), u'abc <a href="http://d.e.f">http://d.e.f</a>') self.assertEqual(next, s.index(", ghi"))
def testNamedEscaped(self): s = ur'abc http://d.e.f|"D\"E\"F" ghi' f = Linker(s, 0) frags, next = f.apply() self.assertTrue(u"".join(frags).startswith(u'abc <a href="http://d.e.f">D"E"F</a>')) self.assertEqual(next, s.index(" ghi"))
def testNamed(self): s = ur"abc http://d.e.f|DEF ghi" f = Linker(s, 0) frags, next = f.apply() self.assertTrue(u"".join(frags).startswith(u'abc <a href="http://d.e.f">DEF</a>')) self.assertEqual(next, s.index(" ghi"))