Add PACFetcher.fetch
Let's not try to download proxies during tests...
This commit is contained in:
parent
215fd2f055
commit
556f49d367
@ -247,8 +247,6 @@ class PACFetcher(QObject):
|
|||||||
self._pac_url = url
|
self._pac_url = url
|
||||||
self._manager = QNetworkAccessManager()
|
self._manager = QNetworkAccessManager()
|
||||||
self._manager.setProxy(QNetworkProxy(QNetworkProxy.NoProxy))
|
self._manager.setProxy(QNetworkProxy(QNetworkProxy.NoProxy))
|
||||||
self._reply = self._manager.get(QNetworkRequest(url))
|
|
||||||
self._reply.finished.connect(self._finish)
|
|
||||||
self._pac = None
|
self._pac = None
|
||||||
self._error_message = None
|
self._error_message = None
|
||||||
|
|
||||||
@ -259,6 +257,11 @@ class PACFetcher(QObject):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return utils.get_repr(self, url=self._pac_url, constructor=True)
|
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()
|
@pyqtSlot()
|
||||||
def _finish(self):
|
def _finish(self):
|
||||||
if self._reply.error() != QNetworkReply.NoError:
|
if self._reply.error() != QNetworkReply.NoError:
|
||||||
|
@ -637,7 +637,9 @@ def proxy_from_url(url):
|
|||||||
|
|
||||||
scheme = url.scheme()
|
scheme = url.scheme()
|
||||||
if scheme in ['pac+http', 'pac+https', 'pac+file']:
|
if scheme in ['pac+http', 'pac+https', 'pac+file']:
|
||||||
return pac.PACFetcher(url)
|
fetcher = pac.PACFetcher(url)
|
||||||
|
fetcher.fetch()
|
||||||
|
return fetcher
|
||||||
|
|
||||||
types = {
|
types = {
|
||||||
'http': QNetworkProxy.HttpProxy,
|
'http': QNetworkProxy.HttpProxy,
|
||||||
|
@ -236,11 +236,12 @@ def fetcher_test(test_str):
|
|||||||
serve_thread.start()
|
serve_thread.start()
|
||||||
try:
|
try:
|
||||||
ready_event.wait()
|
ready_event.wait()
|
||||||
res = pac.PACFetcher(QUrl("pac+http://127.0.0.1:8081"))
|
fetcher = pac.PACFetcher(QUrl("pac+http://127.0.0.1:8081"))
|
||||||
assert res.fetch_error() is None
|
fetcher.fetch()
|
||||||
|
assert fetcher.fetch_error() is None
|
||||||
finally:
|
finally:
|
||||||
serve_thread.join()
|
serve_thread.join()
|
||||||
return res
|
return fetcher
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(QT_VERSION_STR.startswith('5.7') and
|
@pytest.mark.skipif(QT_VERSION_STR.startswith('5.7') and
|
||||||
|
Loading…
Reference in New Issue
Block a user