aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2011-01-05 14:42:39 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:51:44 -0300
commite4eaf410aff780efc4e7f5bc693a7b031938d1c5 (patch)
tree7ffc0f08c77b9018de53b221b990637454809eea /tests
parentcfeea7ec045c1f9e7d4652ed2f672db2977de3a8 (diff)
Fixed QtNetwork test to use '127.0.0.1' instead of 'localhost'
This is necessary to make all test to be able run on any buildbot machine. Fix Http server shutdown sequence to avoid deadlocks. Fixes bug #587 Reviewer: Hugo Parente Lima <hugo.lima@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtNetwork/accessManager_test.py12
-rw-r--r--tests/QtNetwork/basic_auth_test.py19
-rw-r--r--tests/QtNetwork/http_test.py12
3 files changed, 29 insertions, 14 deletions
diff --git a/tests/QtNetwork/accessManager_test.py b/tests/QtNetwork/accessManager_test.py
index 172dab8c8..65a848059 100644
--- a/tests/QtNetwork/accessManager_test.py
+++ b/tests/QtNetwork/accessManager_test.py
@@ -19,20 +19,26 @@ class AccessManagerCase(UsesQCoreApplication):
def tearDown(self):
super(AccessManagerCase, self).tearDown()
+ if self.httpd:
+ self.httpd.shutdown()
+ self.httpd = None
+
+ def goAway(self):
self.httpd.shutdown()
+ self.app.quit()
+ self.httpd = None
def slot_replyFinished(self, reply):
self.assertEqual(type(reply), QNetworkReply)
self.called = True
- self.app.quit()
+ self.goAway()
def testNetworkRequest(self):
manager = QNetworkAccessManager()
manager.finished.connect(self.slot_replyFinished)
- manager.get(QNetworkRequest(QUrl("http://localhost:%s" % self.httpd.port())))
+ manager.get(QNetworkRequest(QUrl("http://127.0.0.1:%s" % self.httpd.port())))
self.app.exec_()
self.assert_(self.called)
- self.httpd.shutdown()
if __name__ == '__main__':
unittest.main()
diff --git a/tests/QtNetwork/basic_auth_test.py b/tests/QtNetwork/basic_auth_test.py
index b095f0938..bc41d65c8 100644
--- a/tests/QtNetwork/basic_auth_test.py
+++ b/tests/QtNetwork/basic_auth_test.py
@@ -15,19 +15,23 @@ class testAuthenticationSignal(UsesQCoreApplication):
self._resultOk = False
def tearDown(self):
- self.httpd.shutdown()
- del self.httpd
+ if self.httpd:
+ self.httpd.shutdown()
+ del self.httpd
super(testAuthenticationSignal, self).tearDown()
+ def goAway(self):
+ self.httpd.shutdown()
+ self.app.quit()
+ self.httpd = None
+
def onAuthRequest(self, hostname, port, auth):
self.assert_(isinstance(auth, QAuthenticator))
self._resultOk = True
- self.app.quit()
-
+ self.goAway()
def testwaitSignal(self):
- http = QHttp()
- http.setHost("localhost", self.httpd.port())
+ http = QHttp('127.0.0.1', self.httpd.port())
http.connect(SIGNAL("authenticationRequired(const QString&, quint16, QAuthenticator*)"), self.onAuthRequest)
path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/")
data = http.get(str(path))
@@ -35,8 +39,7 @@ class testAuthenticationSignal(UsesQCoreApplication):
self.assert_(self._resultOk)
def testwaitSignal2(self):
- http = QHttp()
- http.setHost("localhost", self.httpd.port())
+ http = QHttp('127.0.0.1', self.httpd.port())
# Using new signal slot syntax causes a segfault
http.authenticationRequired.connect(self.onAuthRequest)
path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/")
diff --git a/tests/QtNetwork/http_test.py b/tests/QtNetwork/http_test.py
index ee6eeea2b..b6bfea5ff 100644
--- a/tests/QtNetwork/http_test.py
+++ b/tests/QtNetwork/http_test.py
@@ -16,18 +16,24 @@ class HttpSignalsCase(UsesQCoreApplication):
super(HttpSignalsCase, self).setUp()
self.httpd = TestServer()
self.httpd.start()
- self.http = QHttp('localhost' , self.httpd.port())
+ self.http = QHttp("127.0.0.1" , self.httpd.port())
self.called = False
def tearDown(self):
- self.httpd.shutdown()
+ if self.httpd:
+ self.httpd.shutdown()
+ del self.httpd
self.http = None
self.httpd = None
super(HttpSignalsCase, self).tearDown()
+ def goAway(self):
+ self.httpd.shutdown()
+ self.app.quit()
+
def callback(self, ident):
self.called = True
- self.app.quit()
+ self.goAway()
def testDefaultArgs(self):
#QHttp signal requestStarted signal