Add PACFetcher.fetch

Let's not try to download proxies during tests...
This commit is contained in:
Florian Bruhin 2017-07-03 13:26:15 +02:00
parent 215fd2f055
commit 556f49d367
3 changed files with 12 additions and 6 deletions

View File

@ -247,8 +247,6 @@ class PACFetcher(QObject):
self._pac_url = url
self._manager = QNetworkAccessManager()
self._manager.setProxy(QNetworkProxy(QNetworkProxy.NoProxy))
self._reply = self._manager.get(QNetworkRequest(url))
self._reply.finished.connect(self._finish)
self._pac = None
self._error_message = None
@ -259,6 +257,11 @@ class PACFetcher(QObject):
def __repr__(self):
return utils.get_repr(self, url=self._pac_url, constructor=True)
def fetch(self):
"""Fetch the proxy from the remote URL."""
self._reply = self._manager.get(QNetworkRequest(self._pac_url))
self._reply.finished.connect(self._finish)
@pyqtSlot()
def _finish(self):
if self._reply.error() != QNetworkReply.NoError:

View File

@ -637,7 +637,9 @@ def proxy_from_url(url):
scheme = url.scheme()
if scheme in ['pac+http', 'pac+https', 'pac+file']:
return pac.PACFetcher(url)
fetcher = pac.PACFetcher(url)
fetcher.fetch()
return fetcher
types = {
'http': QNetworkProxy.HttpProxy,

View File

@ -236,11 +236,12 @@ def fetcher_test(test_str):
serve_thread.start()
try:
ready_event.wait()
res = pac.PACFetcher(QUrl("pac+http://127.0.0.1:8081"))
assert res.fetch_error() is None
fetcher = pac.PACFetcher(QUrl("pac+http://127.0.0.1:8081"))
fetcher.fetch()
assert fetcher.fetch_error() is None
finally:
serve_thread.join()
return res
return fetcher
@pytest.mark.skipif(QT_VERSION_STR.startswith('5.7') and