[py-svn] r45866 - in py/branch/session-cleanups/py/test: . rsession

fijal at codespeak.net fijal at codespeak.net
Sun Aug 19 16:13:39 CEST 2007


Author: fijal
Date: Sun Aug 19 16:13:37 2007
New Revision: 45866

Modified:
   py/branch/session-cleanups/py/test/reporter.py
   py/branch/session-cleanups/py/test/rsession/rsession.py
   py/branch/session-cleanups/py/test/rsession/web.py
Log:
Move web server initialization to web.py from rsession.py (where it belongs)


Modified: py/branch/session-cleanups/py/test/reporter.py
==============================================================================
--- py/branch/session-cleanups/py/test/reporter.py	(original)
+++ py/branch/session-cleanups/py/test/reporter.py	Sun Aug 19 16:13:37 2007
@@ -14,7 +14,6 @@
 from py.__.test.representation import Presenter
 
 import sys
-import thread    
 
 class AbstractReporter(object):
     def __init__(self, config, hosts):

Modified: py/branch/session-cleanups/py/test/rsession/rsession.py
==============================================================================
--- py/branch/session-cleanups/py/test/rsession/rsession.py	(original)
+++ py/branch/session-cleanups/py/test/rsession/rsession.py	Sun Aug 19 16:13:37 2007
@@ -40,21 +40,8 @@
         restflag = self.config.option.restreport
         
         if startserverflag and reporter is None:
-            from py.__.test.rsession.web import start_server, exported_methods
-            if self.config.option.runbrowser:
-                from socket import INADDR_ANY
-                port = INADDR_ANY   # pick a random port when starting browser
-            else:
-                port = 8000         # stick to a fixed port otherwise
-            
-            reporter = exported_methods.report
-            httpd = start_server(server_address = ('', port))
-            port = httpd.server_port
-            if self.config.option.runbrowser:
-                import webbrowser, thread
-                # webbrowser.open() may block until the browser finishes or not
-                url = "http://localhost:%d" % (port,)
-                thread.start_new_thread(webbrowser.open, (url,))
+            from py.__.test.rsession.web import start_server_from_config
+            reporter = start_server_from_config(self.config)
         elif reporter is None: 
             if restflag:
                 from py.__.test.rsession.rest import RestReporter

Modified: py/branch/session-cleanups/py/test/rsession/web.py
==============================================================================
--- py/branch/session-cleanups/py/test/rsession/web.py	(original)
+++ py/branch/session-cleanups/py/test/rsession/web.py	Sun Aug 19 16:13:37 2007
@@ -417,6 +417,22 @@
         self.end_headers()
         self.wfile.write(data)
 
+def start_server_from_config(config):
+    if config.option.runbrowser:
+        port = socket.INADDR_ANY
+    else:
+        port = 8000
+
+    httpd = start_server(server_address = ('', port))
+    port = httpd.server_port
+    if config.option.runbrowser:
+        import webbrowser, thread
+        # webbrowser.open() may block until the browser finishes or not
+        url = "http://localhost:%d" % (port,)
+        thread.start_new_thread(webbrowser.open, (url,))
+
+    return exported_methods.report
+
 def start_server(server_address = ('', 8000), handler=TestHandler, start_new=True):
     httpd = HTTPServer(server_address, handler)
 



More information about the pytest-commit mailing list