[py-svn] r10779 - py/dist/py/documentation

hpk at codespeak.net hpk at codespeak.net
Sun Apr 17 17:57:54 CEST 2005


Author: hpk
Date: Sun Apr 17 17:57:54 2005
New Revision: 10779

Modified:
   py/dist/py/documentation/conftest.py
Log:
improve the doc-checking some more. 
Now you can see via '-v' or '--collectonly' 
which links are to be checked. 



Modified: py/dist/py/documentation/conftest.py
==============================================================================
--- py/dist/py/documentation/conftest.py	(original)
+++ py/dist/py/documentation/conftest.py	Sun Apr 17 17:57:54 2005
@@ -60,7 +60,7 @@
         if name == self.fspath.basename: 
             return DocumentationItem(name, parent=self) 
         elif name == 'checklinks': 
-            return LinkCheckerGenerator(name, self) 
+            return LinkCheckerMaker(name, self) 
     
 class DocumentationItem(py.test.Item): 
     def run(self): 
@@ -68,27 +68,41 @@
         restcheck(py.path.svnwc(mypath))
         #linkcheck(mypath) 
 
-class LinkCheckerGenerator(py.test.collect.Generator): 
-    def _getobj(self): 
-        path = self.fspath 
-        def genlinkchecks(): 
-            for lineno, line in py.builtin.enumerate(path.readlines()): 
-                line = line.strip()
-                if line.startswith('.. _'): 
-                    l = line.split(':', 1)
-                    if len(l) != 2: 
-                        continue
-                    tryfn = l[1].strip() 
-                    if tryfn.startswith('http:'): 
-                        if option.checkremote: 
-                            yield urlcheck, tryfn, path, lineno 
-                    elif tryfn.endswith('.html'): 
-                        yield localrefcheck, tryfn, path, lineno 
-                    else: 
-                        # yes, what else? 
-                        pass 
-
-        return genlinkchecks 
+class LinkCheckerMaker(py.test.collect.Collector): 
+    def run(self): 
+        l = []
+        for call, tryfn, path, lineno in genlinkchecks(self.fspath): 
+            l.append(tryfn) 
+        return l
+        
+    def join(self, name): 
+        for call, tryfn, path, lineno in genlinkchecks(self.fspath): 
+            if tryfn == name: 
+                return CheckLink(name, parent=self, args=(tryfn, path, lineno), obj=call)
+      
+class CheckLink(py.test.Function): 
+    def setup(self): 
+        pass 
+    def teardown(self): 
+        pass 
+        
+# generating functions + args as single tests 
+def genlinkchecks(path): 
+    for lineno, line in py.builtin.enumerate(path.readlines()): 
+        line = line.strip()
+        if line.startswith('.. _'): 
+            l = line.split(':', 1)
+            if len(l) != 2: 
+                continue
+            tryfn = l[1].strip() 
+            if tryfn.startswith('http:'): 
+                if option.checkremote: 
+                    yield urlcheck, tryfn, path, lineno 
+            elif tryfn.endswith('.html'): 
+                yield localrefcheck, tryfn, path, lineno 
+            else: 
+                # yes, what else? 
+                pass 
 
 def urlcheck(tryfn, path, lineno): 
     try: 



More information about the pytest-commit mailing list