[pypy-svn] r19591 - pypy/dist/pypy/translator/js/test

ericvrp at codespeak.net ericvrp at codespeak.net
Mon Nov 7 10:24:44 CET 2005


Author: ericvrp
Date: Mon Nov  7 10:24:42 2005
New Revision: 19591

Modified:
   pypy/dist/pypy/translator/js/test/browsertest.py
Log:
Refactor for webbrowser module, now the default browser is used.
(thanks xorAxAx for the hint)


Modified: pypy/dist/pypy/translator/js/test/browsertest.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/browsertest.py	(original)
+++ pypy/dist/pypy/translator/js/test/browsertest.py	Mon Nov  7 10:24:42 2005
@@ -4,26 +4,12 @@
 from cgi  import parse_qs
 from sys  import platform
 from time import sleep
+from webbrowser import open as webbrowser_open
 from pypy.translator.js.log import log
 log = log.browsertest
 
 
 class config:
-
-    #XXX refactor this into using the webbrowser module 
-    #    (http://docs.python.org/lib/module-webbrowser.html)
-    if platform == 'darwin':
-        browser = ('/Applications/Firefox.app/Contents/MacOS/', 'firefox-bin')
-
-        #XXX Safari does not accept a http://... format, it still thinks it's a file://...
-        #browser = ('/Applications/Safari.app/Contents/MacOS/', 'Safari')
-
-    elif platform == 'linux2':
-        browser = ('/usr/bin/', 'firefox')
-
-    else:   #win32...
-        browser = ('', 'firefox-bin')
-        
     http_port = 10001
 
     html_page = """<html>
@@ -78,7 +64,7 @@
     def do_GET(self):
         global do_status
         log('do_GET path', self.path)
-        if self.path != "/":
+        if self.path != "/test.html":
             self.send_error(404, "File not found")
             return
         jstestcase = jstest.jstestcase
@@ -92,7 +78,7 @@
     def do_POST(self):
         global do_status
         log('do_POST path', self.path)
-        if self.path != "/":
+        if self.path != "/test.html":
             self.send_error(404, "File not found")
             return
         form = parse_qs(self.rfile.read(int(self.headers['content-length'])))
@@ -146,17 +132,9 @@
     try:
         driver
     except:
-        browser_path, browser_exe = config.browser
-        cmd = 'killall %(browser_exe)s 2>&1 2>/dev/null' % locals()
-        log(cmd)
-        system(cmd)
-
         driver = BrowserTest()
         driver.start_server(config.http_port)
-
-        cmd = '"%s%s" http://localhost:%d &' % (browser_path, browser_exe, config.http_port)
-        log(cmd)
-        system(cmd)
+        webbrowser_open('http://localhost:%d/test.html' % config.http_port)
 
     result = driver.get_result()
     return result



More information about the Pypy-commit mailing list