Skip to content

Commit

Permalink
Fix crash in TestQgsNetworkContentFetcher under qt5
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 20, 2016
1 parent 4ad5038 commit 774f508
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/src/python/test_qgsnetworkcontentfetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -26,6 +27,8 @@
import threading
import http.server

app = start_app()


class TestQgsNetworkContentFetcher(unittest.TestCase):

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

self.loaded = False

self.app = QCoreApplication([])

def contentLoaded(self):
self.loaded = True

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 774f508

Please sign in to comment.