{"action":"opened","issue":{"url":"https://api.github.com/repos/pytest-dev/pytest-splinter/issues/16","labels_url":"https://api.github.com/repos/pytest-dev/pytest-splinter/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/pytest-dev/pytest-splinter/issues/16/comments","events_url":"https://api.github.com/repos/pytest-dev/pytest-splinter/issues/16/events","html_url":"https://github.com/pytest-dev/pytest-splinter/issues/16","id":55634945,"number":16,"title":"make_screenshot_on_failure: handle \"URLError: Connection refused\"","user":{"login":"blueyed","id":9766,"avatar_url":"https://avatars.githubusercontent.com/u/9766?v=3","gravatar_id":"","url":"https://api.github.com/users/blueyed","html_url":"https://github.com/blueyed","followers_url":"https://api.github.com/users/blueyed/followers","following_url":"https://api.github.com/users/blueyed/following{/other_user}","gists_url":"https://api.github.com/users/blueyed/gists{/gist_id}","starred_url":"https://api.github.com/users/blueyed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blueyed/subscriptions","organizations_url":"https://api.github.com/users/blueyed/orgs","repos_url":"https://api.github.com/users/blueyed/repos","events_url":"https://api.github.com/users/blueyed/events{/privacy}","received_events_url":"https://api.github.com/users/blueyed/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-27T15:51:50Z","updated_at":"2015-01-27T15:51:50Z","closed_at":null,"body":"When quitting the browser yourself in the (overridden) browser fixture,\r\n`make_screenshot_on_failure` causes a \"Connection refused\" exception.\r\n\r\nWhile this indicates a problem with your test setup, I think it should only\r\nlog a warning instead, or something similar.\r\n\r\n    _______ ERROR at teardown of test_submitter_history ______\r\n\r\n        def make_screenshot_on_failure():\r\n            if splinter_make_screenshot_on_failure and request.node.splinter_failure:\r\n                slaveoutput = getattr(request.config, 'slaveoutput', None)\r\n                names = junitxml.mangle_testnames(request.node.nodeid.split(\"::\"))\r\n                classname = '.'.join(names[:-1])\r\n                screenshot_dir = os.path.join(splinter_screenshot_dir, classname)\r\n                screenshot_file_name = '{0}-{1}.png'.format(\r\n                    names[-1][:128 - len(parent.__name__) - 5], parent.__name__)\r\n                if not slaveoutput:\r\n                    if not os.path.exists(screenshot_dir):\r\n                        os.makedirs(screenshot_dir)\r\n                else:\r\n                    screenshot_dir = tmpdir.mkdir('screenshots').strpath\r\n                screenshot_path = os.path.join(screenshot_dir, screenshot_file_name)\r\n    >           browser.driver.save_screenshot(screenshot_path)\r\n\r\n    venv/lib/python2.7/site-packages/pytest_splinter/plugin.py:308:\r\n    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n    venv/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:696: in get_screenshot_as_file\r\n        png = self.get_screenshot_as_png()\r\n    venv/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:715: in get_screenshot_as_png\r\n        return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))\r\n    venv/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:725: in get_screenshot_as_base64\r\n        return self.execute(Command.SCREENSHOT)['value']\r\n    venv/lib/python2.7/site-packages/pytest_splinter/webdriver_patches.py:76: in execute\r\n        result = self._base_execute(driver_command, params)\r\n    venv/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:171: in execute\r\n        response = self.command_executor.execute(driver_command, params)\r\n    venv/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py:349: in execute\r\n        return self._request(command_info[0], url, body=data)\r\n    venv/lib/python2.7/site-packages/pytest_splinter/webdriver_patches.py:61: in _request\r\n        return old_request(*args, **kwargs)\r\n    venv/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py:417: in _request\r\n        resp = opener.open(request)\r\n    ..…/pyenv/2.7.9/lib/python2.7/urllib2.py:431: in open\r\n        response = self._open(req, data)\r\n    ..…/pyenv/2.7.9/lib/python2.7/urllib2.py:449: in _open\r\n        '_open', req)\r\n    ..…/pyenv/2.7.9/lib/python2.7/urllib2.py:409: in _call_chain\r\n        result = func(*args)\r\n    ..…/pyenv/2.7.9/lib/python2.7/urllib2.py:1227: in http_open\r\n        return self.do_open(httplib.HTTPConnection, req)\r\n    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n\r\n    self = <urllib2.HTTPHandler instance at 0x7f86aac10c20>, http_class = <class httplib.HTTPConnection at 0x7f86b2577a10>\r\n    req = <selenium.webdriver.remote.remote_connection.Request instance at 0x7f86aad84e60>, http_conn_args = {}, host = '127.0.0.1:52595'\r\n    h = <httplib.HTTPConnection instance at 0x7f86aaca5248>, err = error(111, 'Connection refused')\r\n\r\n        def do_open(self, http_class, req, **http_conn_args):\r\n            \"\"\"Return an addinfourl object for the request, using http_class.\r\n\r\n                http_class must implement the HTTPConnection API from httplib.\r\n                The addinfourl return value is a file-like object.  It also\r\n                has methods and attributes including:\r\n                    - info(): return a mimetools.Message object for the headers\r\n                    - geturl(): return the original request URL\r\n                    - code: HTTP status code\r\n                \"\"\"\r\n            host = req.get_host()\r\n            if not host:\r\n                raise URLError('no host given')\r\n\r\n            # will parse host:port\r\n            h = http_class(host, timeout=req.timeout, **http_conn_args)\r\n            h.set_debuglevel(self._debuglevel)\r\n\r\n            headers = dict(req.unredirected_hdrs)\r\n            headers.update(dict((k, v) for k, v in req.headers.items()\r\n                                if k not in headers))\r\n\r\n            # We want to make an HTTP/1.1 request, but the addinfourl\r\n            # class isn't prepared to deal with a persistent connection.\r\n            # It will try to read all remaining data from the socket,\r\n            # which will block while the server waits for the next request.\r\n            # So make sure the connection gets closed after the (only)\r\n            # request.\r\n            headers[\"Connection\"] = \"close\"\r\n            headers = dict(\r\n                (name.title(), val) for name, val in headers.items())\r\n\r\n            if req._tunnel_host:\r\n                tunnel_headers = {}\r\n                proxy_auth_hdr = \"Proxy-Authorization\"\r\n                if proxy_auth_hdr in headers:\r\n                    tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]\r\n                    # Proxy-Authorization should not be sent to origin\r\n                    # server.\r\n                    del headers[proxy_auth_hdr]\r\n                h.set_tunnel(req._tunnel_host, headers=tunnel_headers)\r\n\r\n            try:\r\n                h.request(req.get_method(), req.get_selector(), req.data, headers)\r\n            except socket.error, err: # XXX what error?\r\n                h.close()\r\n    >           raise URLError(err)\r\n    E           URLError: <urlopen error [Errno 111] Connection refused>\r\n\r\n    ..…/pyenv/2.7.9/lib/python2.7/urllib2.py:1197: URLError\r\n    -\r\n"}}