Skip to content
Permalink
Browse files
Fix crash in TestQgsNetworkContentFetcher under qt5
  • Loading branch information
nyalldawson committed Sep 20, 2016
1 parent 4ad5038 commit 774f5085a3f3d4756af08cce79768d18ab43dbc0
Showing with 9 additions and 8 deletions.
  1. +9 −8 tests/src/python/test_qgsnetworkcontentfetcher.py
@@ -6,6 +6,7 @@
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
"""

from builtins import chr
from builtins import str
__author__ = 'Matthias Kuhn'
@@ -17,7 +18,7 @@
import qgis # NOQA

import os
from qgis.testing import unittest
from qgis.testing import unittest, start_app
from qgis.core import QgsNetworkContentFetcher
from utilities import unitTestDataPath
from qgis.PyQt.QtCore import QUrl, QCoreApplication
@@ -26,6 +27,8 @@
import threading
import http.server

app = start_app()


class TestQgsNetworkContentFetcher(unittest.TestCase):

@@ -48,8 +51,6 @@ def __init__(self, methodName):

self.loaded = False

self.app = QCoreApplication([])

def contentLoaded(self):
self.loaded = True

@@ -59,7 +60,7 @@ def testFetchEmptyUrl(self):
fetcher.fetchContent(QUrl())
fetcher.finished.connect(self.contentLoaded)
while not self.loaded:
self.app.processEvents()
app.processEvents()

r = fetcher.reply()
assert r.error() != QNetworkReply.NoError
@@ -70,7 +71,7 @@ def testFetchBadUrl(self):
fetcher.fetchContent(QUrl('http://x'))
fetcher.finished.connect(self.contentLoaded)
while not self.loaded:
self.app.processEvents()
app.processEvents()

r = fetcher.reply()
assert r.error() != QNetworkReply.NoError
@@ -81,7 +82,7 @@ def testFetchUrlContent(self):
fetcher.fetchContent(QUrl('http://localhost:' + str(TestQgsNetworkContentFetcher.port) + '/qgis_local_server/index.html'))
fetcher.finished.connect(self.contentLoaded)
while not self.loaded:
self.app.processEvents()
app.processEvents()

r = fetcher.reply()
assert r.error() == QNetworkReply.NoError, r.error()
@@ -97,7 +98,7 @@ def testDoubleFetch(self):
fetcher.fetchContent(QUrl('http://localhost:' + str(TestQgsNetworkContentFetcher.port) + '/qgis_local_server/index.html'))
fetcher.finished.connect(self.contentLoaded)
while not self.loaded:
self.app.processEvents()
app.processEvents()

r = fetcher.reply()
assert r.error() == QNetworkReply.NoError, r.error()
@@ -111,7 +112,7 @@ def testFetchEncodedContent(self):
fetcher.fetchContent(QUrl('http://localhost:' + str(TestQgsNetworkContentFetcher.port) + '/encoded_html.html'))
fetcher.finished.connect(self.contentLoaded)
while not self.loaded:
self.app.processEvents()
app.processEvents()

r = fetcher.reply()
assert r.error() == QNetworkReply.NoError, r.error()

0 comments on commit 774f508

Please sign in to comment.