[Checkins] SVN: gocept.selenium/trunk/ Fixes #6489: Raise readable error when connection to RC server fails

Wolfgang Schnerring wosc at wosc.de
Sat Dec 4 12:45:19 EST 2010


Log message for revision 118707:
  Fixes #6489: Raise readable error when connection to RC server fails
  

Changed:
  U   gocept.selenium/trunk/CHANGES.txt
  U   gocept.selenium/trunk/src/gocept/selenium/base.py
  A   gocept.selenium/trunk/src/gocept/selenium/tests/test_base.py

-=-
Modified: gocept.selenium/trunk/CHANGES.txt
===================================================================
--- gocept.selenium/trunk/CHANGES.txt	2010-12-04 17:34:16 UTC (rev 118706)
+++ gocept.selenium/trunk/CHANGES.txt	2010-12-04 17:45:18 UTC (rev 118707)
@@ -5,6 +5,7 @@
 ----------------
 
 - Show current test case in command log (#7876).
+- Raise readable error when connection to RC server fails (#6489).
 
 
 0.8 (2010-10-22)

Modified: gocept.selenium/trunk/src/gocept/selenium/base.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/base.py	2010-12-04 17:34:16 UTC (rev 118706)
+++ gocept.selenium/trunk/src/gocept/selenium/base.py	2010-12-04 17:45:18 UTC (rev 118707)
@@ -14,6 +14,7 @@
 
 import gocept.selenium.selenese
 import selenium
+import socket
 import sys
 
 
@@ -47,7 +48,13 @@
         self.selenium = selenium.selenium(
             self._server, self._port, self._browser,
             'http://%s:%s/' % (self.host, self.port))
-        self.selenium.start()
+        try:
+            self.selenium.start()
+        except socket.error, e:
+            raise socket.error(
+                'Failed to connect to Selenium RC server at %s:%s,'
+                ' is it running? (%s)'
+                % (self._server, self._port, e))
 
     def tearDown(self):
         self.selenium.stop()

Added: gocept.selenium/trunk/src/gocept/selenium/tests/test_base.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/tests/test_base.py	                        (rev 0)
+++ gocept.selenium/trunk/src/gocept/selenium/tests/test_base.py	2010-12-04 17:45:18 UTC (rev 118707)
@@ -0,0 +1,28 @@
+#############################################################################
+#
+# Copyright (c) 2010 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import gocept.selenium.base
+import unittest
+
+
+class LayerTest(unittest.TestCase):
+
+    def test_connection_refused_should_raise_readable_error(self):
+        layer = gocept.selenium.base.Layer()
+        layer._port = 0 # reserved by IANA
+        try:
+            layer.setUp()
+        except Exception, e:
+            self.assertTrue(str(e).startswith(
+                'Failed to connect to Selenium RC'))



More information about the checkins mailing list