Ejemplo n.º 1
0
 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?&lt;a&gt;+&quot;b&quot;">foo</a>')
   self.assertEqual(next, s.index(" ghi"))
Ejemplo n.º 2
0
 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"))
Ejemplo n.º 3
0
 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"))
Ejemplo n.º 4
0
 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"))
Ejemplo n.º 5
0
 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"))
Ejemplo n.º 6
0
 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"))
Ejemplo n.º 7
0
 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"))
Ejemplo n.º 8
0
 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"))