[py-svn] r36505 - in py/dist/py/apigen: . testing

guido at codespeak.net guido at codespeak.net
Thu Jan 11 16:44:42 CET 2007


Author: guido
Date: Thu Jan 11 16:44:40 2007
New Revision: 36505

Modified:
   py/dist/py/apigen/linker.py
   py/dist/py/apigen/testing/test_linker.py
Log:
(hpk, guido) simplified lazy linking


Modified: py/dist/py/apigen/linker.py
==============================================================================
--- py/dist/py/apigen/linker.py	(original)
+++ py/dist/py/apigen/linker.py	Thu Jan 11 16:44:40 2007
@@ -22,10 +22,8 @@
         assert self.root is None
         self.root = root
 
-    def repr_link(self, linkid, linkcontent=None):
-        if linkcontent is None:
-            linkcontent = linkid
-        return html.a(linkcontent, href=LazyHref(self, linkid))
+    def get_lazyhref(self, linkid):
+        return LazyHref(self, linkid)
 
     def set_link(self, linkid, target):
         assert linkid not in self._linkid2target

Modified: py/dist/py/apigen/testing/test_linker.py
==============================================================================
--- py/dist/py/apigen/testing/test_linker.py	(original)
+++ py/dist/py/apigen/testing/test_linker.py	Thu Jan 11 16:44:40 2007
@@ -1,37 +1,25 @@
 import py
 html = py.xml.html
-from py.__.apigen.source.linker import Linker, getrelfspath
+from py.__.apigen.linker import Linker, getrelfspath
 
 class TestLinker(object):
     def test_one_lazy_link(self):
         linker = Linker()
         linker.set_root('/root')
-        tag = linker.repr_link('py.path.local')
+        lazyhref = linker.get_lazyhref('py.path.local')
         linker.set_link('py.path.local', 'py/path/local.html')
-        resolved = tag.unicode()
-        assert (resolved ==
-                '<a href="/root/py/path/local.html">py.path.local</a>')
+        href = unicode(lazyhref)
+        assert href == '/root/py/path/local.html'
     
-    def test_lazy_link_different_text(self):
-        linker = Linker()
-        linker.set_root('/root')
-        content = html.em('foo')
-        tag = linker.repr_link('py.path.local', content)
-        linker.set_link('py.path.local', 'py/path/local.html')
-        resolved = tag.unicode(indent=0)
-        assert (resolved ==
-                '<a href="/root/py/path/local.html"><em>foo</em></a>')
-
     def test_source_link_getrelfspath(self):
         linker = Linker()
         linker.set_root('/root')
 
         relfspath = getrelfspath('py.path.local')
-        tag = linker.repr_link(relfspath, "sourcelink")
+        lazyhref = linker.get_lazyhref(relfspath)
         linker.set_link(relfspath, "hello/world")
-        resolved = tag.unicode(indent=0)
-        assert (resolved ==
-                '<a href="/root/hello/world">sourcelink</a>')
+        href = unicode(lazyhref)
+        assert href == '/root/hello/world'
 
 # considerations for futurue use
 """



More information about the pytest-commit mailing list