[py-svn] r33775 - in py/dist/py/test: . rsession rsession/webdata

fijal at codespeak.net fijal at codespeak.net
Thu Oct 26 16:40:24 CEST 2006


Author: fijal
Date: Thu Oct 26 16:40:18 2006
New Revision: 33775

Modified:
   py/dist/py/test/cmdline.py
   py/dist/py/test/defaultconftest.py
   py/dist/py/test/rsession/rsession.py
   py/dist/py/test/rsession/web.py
   py/dist/py/test/rsession/webdata/index.html
   py/dist/py/test/rsession/webdata/source.js
   py/dist/py/test/rsession/webjs.py
Log:
Minor fixes of web data. Handle TestFinished event, should catch at least TryiterFailed and TryiterSkipped. [Fijal cries for tests]


Modified: py/dist/py/test/cmdline.py
==============================================================================
--- py/dist/py/test/cmdline.py	(original)
+++ py/dist/py/test/cmdline.py	Thu Oct 26 16:40:18 2006
@@ -23,6 +23,14 @@
     if config.option.apigen and not isinstance(session, AbstractSession):
         print "Cannot generate API without (R|L)Session"
         raise SystemExit, 2
+    if config.option.runbrowser and not config.option.startserver:
+        print "Cannot point browser when not starting server"
+        raise SystemExit, 2
+    try:
+        if config.getinitialvalue('startserver'):
+            py.std.warnings.warn("Startserver flag in config is deprecated, use commandline option istead")
+    except ValueError:
+        pass
     
     try: 
         failures = session.main(args)

Modified: py/dist/py/test/defaultconftest.py
==============================================================================
--- py/dist/py/test/defaultconftest.py	(original)
+++ py/dist/py/test/defaultconftest.py	Thu Oct 26 16:40:18 2006
@@ -67,7 +67,11 @@
                help="python executable to run the tests with. "),
         Option('-w', '--startserver',
                action="store_true", dest="startserver", default=False,
-               help="Start HTTP server listening on localhost for test"
+               help="Start HTTP server listening on localhost:8000 for test"
+               ),
+        Option('', '--runbrowser',
+               action="store_true", dest="runbrowser", default=False,
+               help="Run browser to point to your freshly started web server"
                ),
     )
     

Modified: py/dist/py/test/rsession/rsession.py
==============================================================================
--- py/dist/py/test/rsession/rsession.py	(original)
+++ py/dist/py/test/rsession/rsession.py	Thu Oct 26 16:40:18 2006
@@ -359,6 +359,9 @@
             
             reporter = exported_methods.report
             start_server()
+            if self.config.option.runbrowser:
+                import webbrowser
+                webbrowser.open("localhost:8000")
         elif reporter is None: 
             if arg:
                 reporter_instance = reporter_class(self.config, sshhosts, self.getpkgdir(arg))

Modified: py/dist/py/test/rsession/web.py
==============================================================================
--- py/dist/py/test/rsession/web.py	(original)
+++ py/dist/py/test/rsession/web.py	Thu Oct 26 16:40:18 2006
@@ -18,7 +18,6 @@
 
 from py.__.test.rsession.webdata import json
 
-
 DATADIR = py.path.local(__file__).dirpath("webdata")
 FUNCTION_LIST = ["main", "show_skip", "show_traceback", "show_info", "hide_info"]
 
@@ -246,6 +245,10 @@
             args[key] = value
         return args
     
+    def log_message(self, format, *args):
+        # XXX just discard it
+        pass
+    
     do_POST = do_GET
     
     def run_(self):
@@ -280,6 +283,7 @@
 def start_server(server_address = ('', 8000)):
     httpd = HTTPServer(server_address, TestHandler)
     thread.start_new_thread(httpd.serve_forever, ())
+    print "Server started, listening on %s" % (server_address,)
 
 def kill_server():
     exported_methods.pending_events.put(None)

Modified: py/dist/py/test/rsession/webdata/index.html
==============================================================================
--- py/dist/py/test/rsession/webdata/index.html	(original)
+++ py/dist/py/test/rsession/webdata/index.html	Thu Oct 26 16:40:18 2006
@@ -5,7 +5,7 @@
 </head>
 <body onload="main()">
 <a name="beginning">
-<h3>Tests</h3>
+<h3 id="Tests">Tests</h3>
 </a>
 <div style="visibility:hidden; position:fixed; left:100px; top:10px" id="info">
 </div>

Modified: py/dist/py/test/rsession/webdata/source.js
==============================================================================
Binary files. No diff available.

Modified: py/dist/py/test/rsession/webjs.py
==============================================================================
--- py/dist/py/test/rsession/webjs.py	(original)
+++ py/dist/py/test/rsession/webjs.py	Thu Oct 26 16:40:18 2006
@@ -124,6 +124,9 @@
             module_part.childNodes[-1].appendChild(td)
         except:
             dom.get_document().getElementById("testmain").innerHTML += "some error"
+    elif msg['type'] == 'TestFinished':
+        dom.get_document().title = "Py.test [FINISHED]"
+        dom.get_document().getElementById("Tests").childNodes[0].nodeValue = "Tests [FINISHED]"
     return True
 
 def show_skip(item_name="aa"):



More information about the pytest-commit mailing list